JS實現的論壇Ajax打分效果完整執行個體_javascript技巧

來源:互聯網
上載者:User

本文執行個體講述了JS實現的論壇Ajax打分效果。分享給大家供大家參考,具體如下:

這是論壇常見的一種Ajax打分效果,使用了Discuz老版論壇的就有此種效果,目前有很多網站也有類似的,分享給大家吧,我覺得非常實用的Ajax評分效果,使用了一個背景圖片,自己可以下載。

運行效果截圖如下:

線上示範地址如下:

http://demo.jb51.net/js/2015/js-dicuz-ajax-df-plugs-codes/

具體代碼如下:

<!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><title>論壇Ajax評分效果</title><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css">*{margin:0;padding:0;font-size:12px}#show{font:bold 14px/2 Georgia;text-align:center;}.star{position:relative;width:150px;margin:0 auto;}.star,.index,.star a{overflow:hidden;height:25px;background:url('images/221815eep7piubznelxi3e.gif') repeat-x;color:#FFF;font:0/0 arial;}.index{position:absolute;z-index:1;top:0;left:0;margin:0;background-position:0 -60px;height:25px}.star a{position:absolute;z-index:3;top:0;width:30px;background-position:0 -90px;}.star a:hover{z-index:2;left:0;background-position:0 -30px;}a.star1{left:0;}a.star1:hover{width:30px;}a.star2{left:30px;}a.star2:hover{width:60px;}a.star3{left:60px;}a.star3:hover{width:90px;}a.star4{left:90px;}a.star4:hover{width:120px;}a.star5{left:120px;}a.star5:hover{width:150px;}</style><script>function go(){ var count=sum=distance=0; var dd,a; var as=document.getElementById("rank").getElementsByTagName("a"); var here=document.getElementById("here"); var show=document.getElementById("show"); for(var i=0;i<as.length;i++){  as[i].idx=i+1;  as[i].onclick=function(){   ++count;   this.w=30;   distance+=this.idx*this.w;   here.style.width=distance/count+"px";   dd=parseInt(here.style.width)/30;   a=dd.toString().substr(0,4);   show.innerHTML=a+"分";   return false;  } }}window.onload=function(){go()}</script></head><body><br /><br /><br /><br /><br /><br /><br /><div id="rank" class="star"> <h3 id="here" class="index"></h3> <a title="給1分" href="#" class="star1">1</a> <a title="給2分" href="#" class="star2">2</a> <a title="給3分" href="#" class="star3">3</a> <a title="給4分" href="#" class="star4">4</a> <a title="給5分" href="#" class="star5">5</a></div><div id="show">打分..</div></body></html>

希望本文所述對大家JavaScript程式設計有所協助。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.