下面是html源码,其中需要用到“jquery.min.js”文件和一个“rate.png”文件。
rate.png文件如下:
html源码文件如下:
<!DOCTYPE html>
<!-- saved from url=(0045)http://www.nolure.com/p/demo/jquery-rate.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>jquery星级评论打分组件</title>
<script src="./jquery.min.js"></script>
<link rel="stylesheet" href="http://www.nolure.com/p/css/base.css">
<script>
function onScoreChanged(){
rs = "";
tr = document.getElementById("table_score").getElementsByTagName("tr");
if(tr.length == 0) return;
// get table header
header = tr[0];
for(i=1; i<tr.length; i++){
td = tr[i].getElementsByTagName("td");
rowLabel = td[0].innerHTML;
for(j=1; j<td.length; j++){
}
}
}
/*
* 通用打分组件
* callBack打分后执行的回调
* this.Index:获取当前选中值
*/
var pRate = function(box){
this.Index = null;
var B = $("#"+box),
rate = B.children("i"),
w = rate.width(),
n = rate.length,
me = this;
for(var i=0;i<n;i++){
rate.eq(i).css({
'width':w*(i+1),
'z-index':n-i
});
}
rate.hover(function(){
var S = B.children("i.select");
$(this).addClass("hover").siblings().removeClass("hover");
if($(this).index()>S.index()){
S.addClass("hover");
}
},function(){
rate.removeClass("hover");
})
rate.click(function(){
rate.removeClass("select hover");
$(this).addClass("select");
me.Index = $(this).index() + 1;
B.parents().children("#v_rate")[0].value = "" + me.Index;
alert(B.parents().children("#v_rate")[0].value);
})
}
</script>
<style type="text/css">
.p_rate{height:14px;position:relative;width:80px;overflow:hidden;display:inline-block;background:url(rate.png) repeat-x; }
.p_rate i{position:absolute;top:0;left:0;cursor:pointer;height:14px;width:16px;background:url(rate.png) repeat-x 0 -500px}
.p_rate .select{background-position:0 -32px}
.p_rate .hover{background-position:0 -16px}
.table_score{border:1px solid #DADADA; width:500px; margin:40px 100px;}
.table_score td{border:1px solid #DADADA; width:25%; text-align:center; }
</style>
<link type="text/css" rel="stylesheet" href="chrome-extension://cpngackimfmofbokmjmljamhdncknpmg/style.css">
<script type="text/javascript" charset="utf-8" src="chrome-extension://cpngackimfmofbokmjmljamhdncknpmg/page_context.js"></script>
</head>
<body screen_capture_injected="true">
<table id="table_score" class="table_score">
<tr>
<td></td>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>I</td>
<td>
<span class="p_rate" id="rate11">
<i title="1分" style="width: 16px; z-index: 5;" class=""></i>
<i title="2分" style="width: 32px; z-index: 4;" class=""></i>
<i title="3分" style="width: 48px; z-index: 3;" class=""></i>
<i title="4分" style="width: 64px; z-index: 2;" class=""></i>
<i title="5分" style="width: 80px; z-index: 1;" class=""></i>
</span>
<input id="v_rate" type="hidden">
</td>
<td>
<span class="p_rate" id="rate12">
<i title="1分" style="width: 16px; z-index: 5;" class=""></i>
<i title="2分" style="width: 32px; z-index: 4;" class=""></i>
<i title="3分" style="width: 48px; z-index: 3;" class=""></i>
<i title="4分" style="width: 64px; z-index: 2;" class=""></i>
<i title="5分" style="width: 80px; z-index: 1;" class=""></i>
</span>
<input id="v_rate" type="hidden">
</td>
<td>
<span class="p_rate" id="rate13">
<i title="1分" style="width: 16px; z-index: 5;" class=""></i>
<i title="2分" style="width: 32px; z-index: 4;" class=""></i>
<i title="3分" style="width: 48px; z-index: 3;" class=""></i>
<i title="4分" style="width: 64px; z-index: 2;" class=""></i>
<i title="5分" style="width: 80px; z-index: 1;" class=""></i>
</span>
<input id="v_rate" type="hidden">
</td>
</tr>
<tr>
<td>II</td>
<td>
<span class="p_rate" id="rate21">
<i title="1分" style="width: 16px; z-index: 5;" class=""></i>
<i title="2分" style="width: 32px; z-index: 4;" class=""></i>
<i title="3分" style="width: 48px; z-index: 3;" class=""></i>
<i title="4分" style="width: 64px; z-index: 2;" class=""></i>
<i title="5分" style="width: 80px; z-index: 1;" class=""></i>
</span>
<input id="v_rate" type="hidden">
</td>
<td>
<span class="p_rate" id="rate22">
<i title="1分" style="width: 16px; z-index: 5;" class=""></i>
<i title="2分" style="width: 32px; z-index: 4;" class=""></i>
<i title="3分" style="width: 48px; z-index: 3;" class=""></i>
<i title="4分" style="width: 64px; z-index: 2;" class=""></i>
<i title="5分" style="width: 80px; z-index: 1;" class=""></i>
</span>
<input id="v_rate" type="hidden">
</td>
<td>
<span class="p_rate" id="rate23">
<i title="1分" style="width: 16px; z-index: 5;" class=""></i>
<i title="2分" style="width: 32px; z-index: 4;" class=""></i>
<i title="3分" style="width: 48px; z-index: 3;" class=""></i>
<i title="4分" style="width: 64px; z-index: 2;" class=""></i>
<i title="5分" style="width: 80px; z-index: 1;" class=""></i>
</span>
<input id="v_rate" type="hidden">
</td>
</tr>
</table>
<script>
// getElementsByClassName not supportted in IE8 and previous vertion
var lis = document.getElementById('table_score').getElementsByTagName('span');
for(var i=0;i<lis.length;i++){
var Rate = new pRate(lis[i].id);
}
</script>
<input id="rate_result" type="hidden">
<div>
<object id="ClCache" click="sendMsg" host="" width="0" height="0"></object>
</div>
</body>
</html>
分享到:
相关推荐
本文实例讲述了基于jQuery实现的美观星级评论打分组件代码。分享给大家供大家参考,具体如下: 这款jquery星级评论打分组件,是通用打分组件,callBack打分后执行的回调,this.Index:获取当前选中值。 运行效果截图...
jquery文章评论星级打分效果代码 jquery文章评论星级打分效果代码
jQuery星级评价打分代码基于jquery.1.9.1.min.js制作,点击选择评价星星数量,右侧表单显示星星个数。
jquery投票评论打分插件,设置多个投票评论系统,可支持投票评论打分,带动画的投票评论打分特效。jQuery下载。
jquery打分评星级效果,很好用
jquery投票星级打分插件,不带评论,
jQuery表情评论打分代码是一款通过鼠标悬停图标评论打分。 jQuery表情评论打分代码
jQuery简单星级评价打分代码基于jquery-1.11.0.js制作,包括星级评分、评论内容。
jQuery星级打分效果,类似淘宝或者外卖软件,星级打分给与评价的一个效果
代码简介:jQuery鼠标星级打分特效是一款带有三种打分效果,实用简单代码非常少便于修改。
这是一款十分简洁的带有星级评论按钮,美化textarea评论表单代码,jQuery星级评论表单代码,jQuery星星打分特效。
简洁的jQuery星级评论表单代码
jQuery星级评分插件。该jQuery星级评分插件体积小,速度快。你还可以自定义星星的图案和效果。
jquery进度条投票打分插件多个带动画进度条投票打分
jquery星级选择 jquery星级选择 jquery星级选择 jquery星级选择 jquery星级选择
多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery多附件上传组件、jquery
js模仿淘宝网评论模块星级评论打分功能,jquery