jQuery實(shí)現(xiàn)滑動(dòng)星星評(píng)分效果(每日分享)
每日分享效果,今天分享一個(gè)jQuery滑動(dòng)星星評(píng)分效果。
jQuery星星評(píng)分制作5顆星星鼠標(biāo)滑過(guò)評(píng)分打分效果,可取消評(píng)分結(jié)果,重新打分。
HTML代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/css.css" rel="external nofollow" > <script src="js/jquery.js"></script> </head> <body> <div id="starRating"> <p class="photo"> <span><i class="high"></i><i class="nohigh"></i></span> <span><i class="high"></i><i class="nohigh"></i></span> <span><i class="high"></i><i class="nohigh"></i></span> <span><i class="high"></i><i class="nohigh"></i></span> <span><i class="high"></i><i class="nohigh"></i></span> </p> <p class="starNum">0.0分</p> <div class="bottoms"> <a class="garyBtn cancleStar">取消評(píng)分</a><a class="blueBtn sureStar">確認(rèn)</a> </div> </div> <script> $(function () { //評(píng)分 var starRating = 0; $('.photo span').on('mouseenter',function () { var index = $(this).index()+1; $(this).prevAll().find('.high').css('z-index',1) $(this).find('.high').css('z-index',1) $(this).nextAll().find('.high').css('z-index',0) $('.starNum').html((index*2).toFixed(1)+'分') }) $('.photo').on('mouseleave',function () { $(this).find('.high').css('z-index',0) var count = starRating / 2 if(count == 5) { $('.photo span').find('.high').css('z-index',1); } else { $('.photo span').eq(count).prevAll().find('.high').css('z-index',1); } $('.starNum').html(starRating.toFixed(1)+'分') }) $('.photo span').on('click',function () { var index = $(this).index()+1; $(this).prevAll().find('.high').css('z-index',1) $(this).find('.high').css('z-index',1) starRating = index*2; $('.starNum').html(starRating.toFixed(1)+'分'); alert('評(píng)分:'+(starRating.toFixed(1)+'分')) }) //取消評(píng)分 $('.cancleStar').on('click',function () { starRating = 0; $('.photo span').find('.high').css('z-index',0); $('.starNum').html(starRating.toFixed(1)+'分'); }) //確定評(píng)分 $('.sureStar').on('click',function () { if(starRating===0) { alert('最低一顆星!'); } else { alert('評(píng)分:'+(starRating.toFixed(1)+'分')) } }) }) </script> </body> </html>
CSS代碼:
#starRating .photo span { position: relative; display: inline-block; width: 44px; height: 42px; overflow: hidden; margin-right: 23px; cursor: pointer; } #starRating .photo span:last-child { margin-right: 0px; } #starRating .photo span .nohigh { position: absolute; width: 44px; height: 42px; top: 0; left: 0; background: url("../img/star.png"); } #starRating .photo span .high { position: absolute; width: 44px; height: 42px; top: 0; left: 0; background: url("../img/star1.png"); } #starRating .starNum { font-size: 26px; color: #de4414; margin-top: 4px; margin-bottom: 10px; } #starRating .bottoms { height: 54px; border-top: 1px solid #d8d8d8; } #starRating .photo { margin-top: 30px; } #starRating .bottoms a { margin-bottom: 0; } #starRating .bottoms .garyBtn { margin-right: 57px!important; } #starRating .bottoms a { width: 130px; height: 35px; line-height: 35px; border-radius: 3px; display: inline-block; font-size: 16px; transition: all 0.2s linear; margin: 16px 0 22px; text-align: center; cursor: pointer; } .garyBtn { margin-right: 60px!important; background-color: #e1e1e1; color: #999999; } .blueBtn { background-color: #1968b1; color: #fff; } .blueBtn:hover { background: #0e73d0; }
總結(jié)
以上所述是小編給大家介紹的jQuery實(shí)現(xiàn)滑動(dòng)星星評(píng)分效果(每日分享),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
- jQuery Raty 一款不錯(cuò)的星級(jí)評(píng)分插件
- jQuery+PHP星級(jí)評(píng)分實(shí)現(xiàn)方法
- jQuery超贊的評(píng)分插件(8款)
- jQuery動(dòng)態(tài)星級(jí)評(píng)分效果實(shí)現(xiàn)方法
- jquery實(shí)現(xiàn)用戶打分評(píng)分特效
- jquery插件star-rating.js實(shí)現(xiàn)星級(jí)評(píng)分特效
- 使用jQuery實(shí)現(xiàn)星級(jí)評(píng)分代碼分享
- jquery實(shí)現(xiàn)類似淘寶星星評(píng)分功能有截圖
- jquery實(shí)現(xiàn)類似淘寶星星評(píng)分功能實(shí)例
- jquery五角星評(píng)分插件示例分享
- jQuery插件-jRating評(píng)分插件源碼分析及使用方法
- 基于jQuery的星級(jí)評(píng)分插件
相關(guān)文章
jQuery實(shí)現(xiàn)橫向帶緩沖的水平運(yùn)動(dòng)效果(附demo源碼下載)
這篇文章主要介紹了jQuery實(shí)現(xiàn)橫向帶緩沖的水平運(yùn)動(dòng)效果,涉及jQuery中鼠標(biāo)事件及animate方法使用技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-01-01快速學(xué)習(xí)jQuery插件 jquery.validate.js表單驗(yàn)證插件使用方法
快速學(xué)習(xí)jQuery插件中的jquery.validate.js表單驗(yàn)證插件使用方法,Validation是歷史最悠久的jQuery插件之一,經(jīng)過(guò)了全球范圍內(nèi)不同項(xiàng)目的驗(yàn)證,并得到了許多Web開(kāi)發(fā)者的好評(píng),感興趣的小伙伴們可以參考一下2015-12-12jquery滾動(dòng)組件(vticker.js)實(shí)現(xiàn)頁(yè)面動(dòng)態(tài)數(shù)據(jù)的滾動(dòng)效果
本文為大家想你想介紹下jquery實(shí)現(xiàn)頁(yè)面動(dòng)態(tài)數(shù)據(jù)的滾動(dòng)效果。似乎只有通過(guò)div-ul-li標(biāo)簽嵌套的方式才能實(shí)現(xiàn)表格多行多列的滾動(dòng)效果2013-07-07jQuery+PHP+MySQL實(shí)現(xiàn)無(wú)限級(jí)聯(lián)下拉框效果
這篇文章主要介紹了jQuery+PHP+MySQL實(shí)現(xiàn)無(wú)限級(jí)聯(lián)效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-02-02