이미지 없이 구현하는 간단한 별점 기능 제이쿼리 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

이미지 없이 구현하는 간단한 별점 기능 제이쿼리 정보

jQuery 이미지 없이 구현하는 간단한 별점 기능 제이쿼리

본문

 

<p class="star_rating">

    <a href="#" class="on">★</a>

    <a href="#" class="on">★</a>

    <a href="#" class="on">★</a>

    <a href="#">★</a>

    <a href="#">★</a>

</p>

 css

 

 

.star_rating {font-size:0; letter-spacing:-4px;}

.star_rating a {

    font-size:22px;

    letter-spacing:0;

    display:inline-block;

    margin-left:5px;

    color:#ccc;

    text-decoration:none;

}

.star_rating a:first-child {margin-left:0;}

.star_rating a.on {color:#777;}

 

Jquery

 

 

$( ".star_rating a" ).click(function() {

     $(this).parent().children("a").removeClass("on");

     $(this).addClass("on").prevAll("a").addClass("on");

     return false;

});

 

★ ★ ★ ★ ★

추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로