jquery星級(jí)插件、支持頁面中多次使用

二話不說,帖代碼:
html代碼
<div class="xing">
<span style="float: left">總體評(píng)價(jià):<font color="#CC3300" size="-1">*</font></span><div
class="rating-wrap">
<ul id="xing1">
<li><a href="javascript:;" data-rate-value="10" data-hint="很差" title="很差" class="one-star">
</a></li>
<li><a href="javascript:;" data-rate-value="20" data-hint="差" title="差" class="two-stars ">
</a></li>
<li><a href="javascript:;" data-rate-value="30" data-hint="還行" title="還行" class="three-stars ">
</a></li>
<li><a href="javascript:;" data-rate-value="40" data-hint="好" title="好" class="four-stars">
</a></li>
<li><a href="javascript:;" data-rate-value="50" data-hint="很好" title="很好" class="five-stars">
</a></li>
</ul>
</div>
<span class="xing1">點(diǎn)擊星星開始打分</span>
</div>
<divclass="xing">
<span style="float: left">廣告效果:<font color="#CC3300"size="-1">*</font></span><div
class="rating-wrap">
<ulid="xing2">
<li><a href="javascript:;" data-rate-value="10" data-hint="很差" title="很差" class="one-star">
</a></li>
<li><a href="javascript:;" data-rate-value="20" data-hint="差" title="差" class="two-stars ">
</a></li>
<li><a href="javascript:;" data-rate-value="30" data-hint="還行" title="還行" class="three-stars ">
</a></li>
<li><a href="javascript:;" data-rate-value="40" data-hint="好" title="好" class="four-stars">
</a></li>
<li><a href="javascript:;" data-rate-value="50" data-hint="很好" title="很好" class="five-stars">
</a></li>
</ul>
</div>
<span class="xing2">點(diǎn)擊星星開始打分</span>
</div>
JS代碼
<script type="text/javascript" src="js/jQuery_1.42.js"></script>
<script type="text/javascript">
$(function(){
$(".rating-wrap a").mouseover(function(){
$(this).parent().siblings().find("a").removeClass("active-star");
$(this).addClass("active-star");
$("."+$(this).parent().parent().attr("id")).html($(this).attr("data-hint"))
}).mouseleave(function(){
var selectID=$(this).parent().parent().attr("id")+"select";
$(this).removeClass("active-star");
if($("#"+selectID).length==0)
{
$("."+$(this).parent().parent().attr("id")).removeClass("active-hint").html("點(diǎn)擊星星開始打分");
}
else
{
$("."+$(this).parent().parent().attr("id")).html($("#"+selectID).attr("data-hint"));
$("#"+selectID).addClass("active-star");
}
}).click(function(){
$(this).addClass("active-star").attr('id',$(this).parent().parent().attr("id")+"select");
$(this).parent().siblings().find("a").attr("id","");
$("."+$(this).parent().parent().attr("id")).html($(this).attr("data-hint")).addClass("active-hint");
})
})
</script>
css代碼
<style>
.item-rank-rst, .user-rank-rst, .rating-wrap ul, .rating-wrap a:hover, .rating-wrap .active-star, .user-m-star, .urr-rank60, .breadcrumb .note {
background-image: url(xing_bg.png);/**-----星級(jí)插件背景圖片----**/
background-repeat: no-repeat;
}
.rating-wrap {
background: none repeat scroll 0 0 #FFF9F1;
border: 1px solid #EFE0D7;
display: inline-block;
float: left;
height: 20px;
margin-right: 5px;
padding: 4px 0 0 5px;
position: relative;
top: -2px;
width: 89px;
z-index: 0;
}
.rating-wrap ul {
background-position: 0 -250px;
height: 16px;
position: relative;
width: 85px;
z-index: 10;
}
.rating-wrap li {
display: inline;
}
.rating-wrap a {
display: block;
height: 16px;
left: 0;
position: absolute;
top: 0;
}
.rating-wrap .five-stars {
background-position: 0 -160px;
width: 84px;
z-index: 10;
}
.rating-wrap .four-stars {
background-position: 0 -178px;
width: 68px;
z-index: 20;
}
.rating-wrap .three-stars {
background-position: 0 -196px;
width: 51px;
z-index: 30;
}
.rating-wrap .two-stars {
background-position: 0 -214px;
width: 34px;
z-index: 40;
}
.rating-wrap .one-star {
background-position: 0 -232px;
width: 17px;
z-index: 50;
}
.rating-block .hint {
color: #999999;
float: left;
}
.active-hint {
color: #CC0000;
}
.rating-block .err-hint {
color: #EE0000;
font-weight: bold;
}
</style>
注:css代碼從項(xiàng)目中分解出,有一小部分沒貼完,大家可以根據(jù)自己的需求修改css style
- jQuery Raty 一款不錯(cuò)的星級(jí)評(píng)分插件
- 如何實(shí)現(xiàn)星星評(píng)價(jià)(jquery.raty.js插件)
- 基于jQuery的星級(jí)評(píng)分插件
- jQuery滿意度星級(jí)評(píng)價(jià)插件特效代碼分享
- jquery插件star-rating.js實(shí)現(xiàn)星級(jí)評(píng)分特效
- jQuery插件-jRating評(píng)分插件源碼分析及使用方法
- jquery五角星評(píng)分插件示例分享
- jQuery超贊的評(píng)分插件(8款)
- jQuery Raty星級(jí)評(píng)分插件使用方法實(shí)例分析
相關(guān)文章
jQuery實(shí)現(xiàn)360°全景拖動(dòng)展示
360全景就是視角超過人的正常視角的圖像,而我們這里說的全景特指水平視角360度,垂直視角180度的圖像??梢匀翱臻g里進(jìn)行切換,達(dá)到瀏覽各個(gè)不同場景360全景展示的目的。2015-03-03jQuery實(shí)現(xiàn)密?;コ鈫栴}解決方案
密保通常都會(huì)有n個(gè)問題,讓用戶選擇其中2、3個(gè),而且都不會(huì)讓用戶選擇重復(fù)的問題。這就要求密?;コ?,具體實(shí)現(xiàn)如下,有此需求的朋友可以參考下2013-08-08jquery通過visible來判斷標(biāo)簽是否顯示或隱藏
這篇文章主要介紹了jquery如何判斷標(biāo)簽是否顯示或隱藏,使用到了visible屬性,大家可以學(xué)習(xí)下2014-05-05jquery實(shí)現(xiàn)的縮略圖預(yù)覽滑塊實(shí)例
這篇文章主要介紹了jquery實(shí)現(xiàn)的縮略圖預(yù)覽滑塊,實(shí)例分析了jQuery縮略圖預(yù)覽滑塊的實(shí)現(xiàn)與使用技巧,并提供了完整的實(shí)例下載,需要的朋友可以參考下2015-06-06jquery二級(jí)導(dǎo)航內(nèi)容均分的原理及實(shí)現(xiàn)
頭部導(dǎo)航二級(jí)導(dǎo)航有些內(nèi)容太長,一列的話太過難看,就要分成兩列,要做到按塊盡量均分,排列順序沒有限制2013-08-08jQuery實(shí)現(xiàn)的自動(dòng)加載頁面功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的自動(dòng)加載頁面功能,結(jié)合簡單實(shí)例形式分析了jQuery針對(duì)頁面元素的動(dòng)態(tài)加載與屬性操作相關(guān)技巧,需要的朋友可以參考下2016-09-09一款Jquery 分頁插件的改造方法(服務(wù)器端分頁)
分頁幾乎是每個(gè)外部程序必不可少的東西,在webform時(shí)代很多人都用過AspNetPager這個(gè)用戶控件吧,用的人之多其實(shí)就在于它的優(yōu)點(diǎn)2011-07-07給jQuery方法添加回調(diào)函數(shù)一款插件的應(yīng)用
本插件用于給jQuery方法添加回調(diào)函數(shù),可在類方法或?qū)嵗椒ㄌ砑尤魏巫远x的回調(diào)函數(shù)而不影響原方法的行為,感興趣的朋友可以了解下,希望本文對(duì)你有所幫助2013-01-01修復(fù)jQuery tablesorter無法正確排序的bug(加千分位數(shù)字后)
這篇文章主要介紹了如何修復(fù)jQuery tablesorter無法正確排序的bug(加千分位數(shù)字后)的相關(guān)資料,需要的朋友可以參考下2016-03-03