<html>
<title>JQuery星星评级 http://meego123.net/</title>
<head>
<script src="jquery-1.3.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var ltupper=["一","二","三","四","五"];
$(document).ready(function(){
$('.star_rating li a').each(function(){
$(this).click(function(){
var lt=getStars($(this).attr('class'));//通过类名判断星星数
$('#stars').val(lt);
$('#selectStars').text(ltupper[lt-1]+'星');
$('.star_rating li a').slice(0,lt).css({'background':'url(images/yellow.jpg)'});
$('.star_rating li a').slice(lt,5).css({'background':'url(images/while.jpg)'});
})
})
$('.star_rating li a').hover(function(){
var lt=getStars($(this).attr('class'));
$('.star_rating li a').slice(0,lt).css({'background':'url(images/yellow.jpg)'});
$('.star_rating li a').slice(lt,5).css({'background':'url(images/while.jpg)'});
$('#selectStars').text(ltupper[lt-1]+'星');
},function(){
var lt=Number($('#stars').val());
if(lt==""){
$('#selectStars').text('(最高为5星)');
}else{
$('#selectStars').text(ltupper[lt-1]+'星');
}
$('.star_rating li a').slice(0,lt).css({'background':'url(images/yellow.jpg)'});
$('.star_rating li a').slice(lt,5).css({'background':'url(images/while.jpg)'});
})
})
//通过类名判断星星数
function getStars(stars){
var re=1;
switch(stars){
case 'one_star':re=1;break;
case 'two_stars':re=2;break;
case 'three_stars':re=3;break;
case 'four_stars':re=4;break;
case 'five_stars':re=5;break;
}
return re;
}
</script>
<style type="text/css">
<!--
.star_rating {float:left;display:block;list-style:none;margin:-1px 0 0 -1px; padding:0; width:80px; height:16px; position:relative; background:url(images/white.jpg) 0 0 repeat-x; overflow:hidden;font-size:0;}
.star_rating li{padding:0;margin:0;float:left;}
.star_rating li a{display:block;width:16px;height:16px;text-decoration:none;text-indent:-9000px;z-index:20;position:absolute;padding:0;margin:0;}
.star_rating li a:hover{background:url(images/yellow.jpg) 0 16px;z-index:2;left:0;}
.star_rating a.one_star{left:0;}
.star_rating a.one_star:hover{width:16px;}
.star_rating a.two_stars{left:16px;}
.star_rating a.two_stars:hover{width:32px;}
.star_rating a.three_stars{left:32px;}
.star_rating a.three_stars:hover{width:48px;}
.star_rating a.four_stars{left:48px;}
.star_rating a.four_stars:hover{width:64px;}
.star_rating a.five_stars{left:64px;}
.star_rating a.five_stars:hover{width:80px;}
-->
</style>
</head>
<body>
<div style="display:block;float:left;width:100px;"><span>*</span> 总体评价:</div>
<ul class="star_rating">
<li><a href="javascript:void(0)" title="1 of 5 stars" class="one_star">1</a></li>
<li><a href="javascript:void(0)" title="2 of 5 stars" class="two_stars">2</a></li>
<li><a href="javascript:void(0)" title="3 of 5 stars" class="three_stars">3</a></li>
<li><a href="javascript:void(0)" title="4 of 5 stars" class="four_stars">4</a></li>
<li><a href="javascript:void(0)" title="5 of 5 stars" class="five_stars">5</a></li>
<li style="display:none;">
<input type="hidden" id="stars" value="" />
</li>
</ul>
<span id="selectStars" style="padding-left:10px;">(最高为5星)</span>
</div>
</body>
</html>
分享到:
相关推荐
自己在csdn.net下了一个觉得不好用于是在网上继续找,终于找到了,共享给大家用下,星星评分,支持半颗星,兼容火狐!jQuery ,图片我觉得自己用不错了,你如果不喜欢图片颜色自己在PS里面调吧。
jQuery星星评分代码基于jquery-1.8.0.min.js制作,可一颗星或半颗星评分。
jQuery星星评分插件鼠标滑动星星打分代码jQuery星星评分插件鼠标滑动星星打分代码
jQuery滑动星星评分代码,5颗星星鼠标滑过评分打分效果,可取消评分结果,重新打分。
实用的jquery星星评分效果代码是一款简单的jQuery滑动星星评分代码,鼠标滑到星星上高亮显示,点击评分效果代码。
jquery滑动星星评分效果代码
jquery星星打分评论_滑动星星打分评论代码 jquery星星打分评论_滑动星星打分评论代码
jquery星星评分插件
非常漂亮的jquery罗盘时钟代码,值得下载收藏
jQuery鼠标滑动星星打分代码是一款星星评分插件,支持半颗星和分数显示,多种星星打分样式效果代码。
jquery点击星星打分效果代码
jQuery鼠标滑动星星打分代码是一款星星评分插件,支持半颗星和分数显示,多种星星打分样式效果代码。
jQuery星星评分插件鼠标滑动星星打分代码【完美支持web、移动端】
jQuery实战 源代码 JQuery实战 源代码 JQuery
jQuery柱状统计图表代码是一款每月店铺人数流量统计图表,可自定义拖动设置总人数和单日人数效果代码。
jQuery拼图相册代码.真的很炫的哦。
jquery简单实例代码,适合初学者入门。
这是李炎恢录制的jQuery视频配套的讲义代码文件,虽然讲义文件不是66个,但是和jQuery 66集的视频文件刚好吻合,欢迎下载~~~~
jquery弹出代码、div弹出代码