<script type="text/javascript">
$('.star').mouseover(function (){
var star = $(this).index() 1;
$(this).parent().css("background-position","0 -" (32 * star) "px");
});
$('.star-rating').mouseout(function (){
var originalresult = $(this).attr('id').split('result')[1];
$(this).css("background-position","0 -" (32 * originalresult) "px");
});
</script>
<div class="star-rating" id="rating1result0">
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
</div>
<div class="result">
<span style="color:green">0</span> (0)
</div>
我收到以下 2 条错误消息:
SyntaxError: missing ) 在参数列表之后
$(this).parent().css("background-position","0 -" (32 * star) "px");
和语法错误:缺失;声明之前
var star = $(this).index() 1;