基于jQuery實(shí)現(xiàn)的美觀星級(jí)評(píng)論打分組件代碼
本文實(shí)例講述了基于jQuery實(shí)現(xiàn)的美觀星級(jí)評(píng)論打分組件代碼。分享給大家供大家參考,具體如下:
這款jquery星級(jí)評(píng)論打分組件,是通用打分組件,callBack打分后執(zhí)行的回調(diào),this.Index:獲取當(dāng)前選中值。
運(yùn)行效果截圖如下:

在線演示地址如下:
http://demo.jb51.net/js/2015/jquery-rate-dfzj-codes/
具體代碼如下:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jquery星級(jí)評(píng)論打分組件</title>
<script src="jquery-1.6.2.min.js"></script>
<script>
var pRate = function(box,callBack){
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;
if(callBack){callBack();}
})
}
</script>
<style type="text/css">
h1{font:26px/3 'microsoft yahei','simhei';color:#000;text-indent:2em;text-shadow:1px 1px 2px #ccc}
.p_rate{height:14px;position:relative;width:80px;overflow:hidden;display:inline-block;background:url(images/rate.png) repeat-x;margin:40px 100px}
.p_rate i{position:absolute;top:0;left:0;cursor:pointer;height:14px;width:16px;background:url(images/rate.png) repeat-x 0 -500px}
.p_rate .select{background-position:0 -32px}
.p_rate .hover{background-position:0 -16px}
</style>
</head>
<body>
<h1>jquery星級(jí)評(píng)論打分組件</h1>
<span class="p_rate" id="p_rate">
<i title="1分"></i>
<i title="2分"></i>
<i title="3分"></i>
<i title="4分"></i>
<i title="5分"></i>
</span>
<script>
var Rate = new pRate("p_rate",function(){
alert(Rate.Index+'分')
});
</script>
</body>
</html>
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- jquery 新浪網(wǎng)易的評(píng)論塊制作
- jquery實(shí)現(xiàn)仿新浪微博評(píng)論滾動(dòng)效果
- 基于jquery實(shí)現(xiàn)ajax無(wú)刷新評(píng)論
- jQuery實(shí)現(xiàn)的簡(jiǎn)單無(wú)刷新評(píng)論功能示例
- jQuery 實(shí)現(xiàn)評(píng)論等級(jí)好評(píng)差評(píng)特效
- JQuery實(shí)現(xiàn)動(dòng)態(tài)添加刪除評(píng)論的方法
- PHP結(jié)合jQuery實(shí)現(xiàn)的評(píng)論頂、踩功能
- jQuery基于ajax實(shí)現(xiàn)星星評(píng)論代碼
- C#使用jQuery實(shí)現(xiàn)無(wú)刷新評(píng)論提交的方法
- jQuery實(shí)現(xiàn)簡(jiǎn)單評(píng)論區(qū)
相關(guān)文章
Jquery多選框互相內(nèi)容交換的實(shí)例代碼
這篇文章介紹了Jquery多選框互相內(nèi)容交換的實(shí)例代碼,有需要的朋友可以參考一下2013-07-07
jQuery基于ajax()使用serialize()提交form數(shù)據(jù)的方法
這篇文章主要介紹了jQuery基于ajax()使用serialize()提交form數(shù)據(jù)的方法,結(jié)合實(shí)例形式較為詳細(xì)的分析了jQuery使用ajax提交serialize序列化后的表單數(shù)據(jù)的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-12-12
基于jQuery的$.getScript方法去加載javaScript文檔解析
下面小編就為大家?guī)硪黄趈Query的$.getScript方法去加載javaScript文檔解析。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-11
jQuery中clone()函數(shù)實(shí)現(xiàn)表單中增加和減少輸入項(xiàng)
這篇文章給大家介紹了jQuery中clone()函數(shù)實(shí)現(xiàn)表單中增加和減少輸入項(xiàng)的實(shí)例代碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-05-05

