本文实例讲述了JS实现的论坛Ajax打分效果。分享给大家供大家参考,具体如下:
这是论坛常见的一种Ajax打分效果,使用了Discuz老版论坛的就有此种效果,目前有很多网站也有类似的,分享给大家吧,我觉得非常实用的Ajax评分效果,使用了一个背景图片,自己可以下载。
运行效果截图如下:
在线演示地址如下:
具体代码如下:
/p>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
论坛Ajax评分效果*{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;}
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[i].idx=i+1;
as[i].οnclick=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.οnlοad=function(){go()}
希望本文所述对大家JavaScript程序设计有所帮助。