国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery動態星級評分效果實現方法

2019-11-20 11:53:45
字體:
來源:轉載
供稿:網友

本文實例講述了jQuery動態星級評分效果實現方法。分享給大家供大家參考。具體如下:

這里的jQuery星級評分代碼,是大家都很喜歡的功能,目前廣泛應用,本星級評分加入了動畫效果,注意,如果要真正實現星級評分,你需要動態程序配合,如ASP/PHP等,以便將評分值存入數據庫。

運行效果如下圖所示:

具體代碼如下:

<!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超漂亮星級評分</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(//files.VeVB.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(//files.VeVB.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>如果運行錯誤請刷新頁面即可~</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>

希望本文所述對大家的jquery程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 杭州市| 黄骅市| 称多县| 岑巩县| 安多县| 奉贤区| 正蓝旗| 驻马店市| 柏乡县| 咸宁市| 屏东县| 颍上县| 徐闻县| 青川县| 凤山市| 贵定县| 会昌县| 尉氏县| 兴山县| 抚远县| 宜君县| 丹江口市| 平南县| 临沭县| 遵化市| 安福县| 巫溪县| 密山市| 长阳| 陆河县| 贺兰县| 萝北县| 增城市| 林芝县| 科技| 安西县| 察雅县| 丽水市| 壶关县| 麻江县| 杭州市|