jQuery動(dòng)態(tài)星級(jí)評(píng)分效果實(shí)現(xiàn)方法
本文實(shí)例講述了jQuery動(dòng)態(tài)星級(jí)評(píng)分效果實(shí)現(xiàn)方法。分享給大家供大家參考。具體如下:
這里的jQuery星級(jí)評(píng)分代碼,是大家都很喜歡的功能,目前廣泛應(yīng)用,本星級(jí)評(píng)分加入了動(dòng)畫效果,注意,如果要真正實(shí)現(xiàn)星級(jí)評(píng)分,你需要?jiǎng)討B(tài)程序配合,如ASP/PHP等,以便將評(píng)分值存入數(shù)據(jù)庫(kù)。
運(yùn)行效果如下圖所示:
具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery超漂亮星級(jí)評(píng)分</title> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <style> .user_rate {font-size:14px; position:relative; padding:10px 0;} .user_rate p {margin:0; padding:0; display:inline; height:40px; overflow:hidden; position:absolute; top:0; left:100px; margin-left:140px;} .user_rate p span.s {font-size:36px; line-height:36px; float:left; font-weight:bold; color:#DD5400;} .user_rate p span.g {font-size:22px; display:block; float:left; color:#DD5400;} .big_rate_bak {width:140px; height:28px; text-align:left; position:absolute; top:3px; left:85px; display:inline-block; background:url(//img.jbzj.com/file_images/article/201508/201586174000242.gif) left bottom repeat-x;} .big_rate_bak b {display:inline-block; width:24px; height:28px; position:relative; z-index:1000; cursor:pointer; overflow:hidden;} .big_rate_up {width:140px; height:28px; position:absolute; top:0; left:0; background:url(//img.jbzj.com/file_images/article/201508/201586174000242.gif) left top;} </style> </head> <body> <div class="user_rate"> <div class="big_rate_bak"> <b rate="2" onclick="javascript:up_rate(20);"> </b> <b rate="4" onclick="javascript:up_rate(40);"> </b> <b rate="6" onclick="javascript:up_rate(60);"> </b> <b rate="8" onclick="javascript:up_rate(80);"> </b> <b rate="10" onclick="javascript:up_rate(100);"> </b> <div style="width:45px;" class="big_rate_up"></div> </div> <p><span id="s" class="s"></span><span id="g" class="g"></span></p> </div> <br><br>如果運(yùn)行錯(cuò)誤請(qǐng)刷新頁(yè)面即可~ </body> <script type="text/javascript"> $(function(){ get_rate(88); }) function get_rate(rate){ rate=rate.toString(); var s; var g; $("#g").show(); if (rate.length>=3){ s=10; g=0; $("#g").hide(); }else if(rate=="0"){ s=0; g=0; }else{ s=rate.substr(0,1); g=rate.substr(1,1); } $("#s").text(s); $("#g").text("."+ g); $(".big_rate_up").animate({width:(parseInt(s)+parseInt(g)/10) * 14,height:26},1000); $(".big_rate_bak b").each(function(){ $(this).mouseover(function(){ $(".big_rate_up").width($(this).attr("rate") * 14 ); $("#s").text($(this).attr("rate")); $("#g").text(""); }).click(function(){ $("#f").text($(this).attr("rate")); $("#my_rate").show(); }) }) $(".big_rate_bak").mouseout(function(){ $("#s").text(s); $("#g").text("."+ g); $(".big_rate_up").width((parseInt(s)+parseInt(g)/10) * 14); }) } function up_rate(rate){ $(".big_rate_up").width("0"); get_rate(rate); } </script> </html>
希望本文所述對(duì)大家的jquery程序設(shè)計(jì)有所幫助。
- jQuery超贊的評(píng)分插件(8款)
- 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)分插件
- 如何基于jQuery實(shí)現(xiàn)五角星評(píng)分
相關(guān)文章
jQuery實(shí)現(xiàn)表格的數(shù)據(jù)拖拽
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)表格的數(shù)據(jù)拖拽,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-02-02jQuery鼠標(biāo)懸停內(nèi)容動(dòng)畫切換效果
本篇文章主要介紹了jQuery鼠標(biāo)懸停內(nèi)容動(dòng)畫切換效果的實(shí)例。具有很好的參考價(jià)值。下面跟著小編一起來看下吧2017-04-04js頁(yè)面滾動(dòng)時(shí)層智能浮動(dòng)定位實(shí)現(xiàn)(jQuery/MooTools)
關(guān)于層的智能浮動(dòng)效果早在幾年前我就在國(guó)外的一些個(gè)人網(wǎng)站的垂直導(dǎo)航上見到了,現(xiàn)在似乎在國(guó)內(nèi)一些商業(yè)網(wǎng)站上也屢見此效果2011-08-08JQuery 實(shí)現(xiàn)在同一頁(yè)面錨點(diǎn)鏈接之間的平滑滾動(dòng)
JQuery 原來比我想象的要強(qiáng)大的多,本文用 JQuery 實(shí)現(xiàn)錨點(diǎn)鏈接之間的平滑滾動(dòng),在同一頁(yè)面的錨點(diǎn)鏈接之間實(shí)現(xiàn)平滑的滾動(dòng)2014-10-10