很酷的javascript 星級評等效果

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.111cn.net/1999/xhtml"><head><title>很酷的星級評等效果</title><meta http-equiv="content-type" content="text/html;charset=gb2312"><!--把下面代碼加到<head>與</head>之間--><style type="text/css">.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;}/*rating*/.big_rate_bak {width:140px; height:28px; text-align:left; position:absolute; top:3px; left:85px; display:inline-block; background:url(yun_qi_img/20100526183731.gif) left -32px repeat-x;}.big_rate_bak b {display:inline-block; width:28px;float:left; 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(yun_qi_img/20100526183731.gif) left top;}</style><script type="text/javascript" src="http://www.111cn.net/demo/jquerys.js"></script></head><body>預覽效果時左下角會提示錯誤,而且看不到效果,重新整理一下就可以看到效果了;當然,在實際使用中,不會出現這樣的問題。<br><!--把下面代碼加到<body>與</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 class="big_rate_up"></div> </div> <p><span id="s" class="s"></span><span id="g" class="g"></span></p></div><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></body></html>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.