Rumah > Artikel > hujung hadapan web > csdn 论坛技术区平均给分功能_javascript技巧
1每人平均给分(重复回复的只给一次分):
javascript:var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};var n=function(name){return document.getElementsByName(name)};var total=t("var")[0].innerHTML-0;var scores=n("tb_score");var lz=t("a",t("var")[0].parentNode)[0].innerHTML;var c={};c[lz]=lz;for(var i=0;i
源代码:
var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};
var n=function(name){return document.getElementsByName(name)};
var total=t("var")[0].innerHTML-0;
var scores=n("tb_score");
var lz=t("a",t("var")[0].parentNode)[0].innerHTML;
var c={};
c[lz]=lz;
for(var i=0;i
if(!c[v]) {
c[v]=v;
scores[i].value=scores[i].value-0+1;
total--;
if(total==0)break;
}
if(i==scores.length-1){i=-1;c={};c[lz]=lz;}
};
alert("ok");
2每楼平均给分:
javascript:var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};var n=function(name){return document.getElementsByName(name)};var total=t("var")[0].innerHTML-0;var scores=n("tb_score");var lz=t("a",t("var")[0].parentNode)[0].innerHTML;for(var i=0;i
源代码:
var t=function(tag,s) { return (s ||document).getElementsByTagName(tag);};
var n=function(name){return document.getElementsByName(name)};
var total=t("var")[0].innerHTML-0;
var scores=n("tb_score");
var lz=t("a",t("var")[0].parentNode)[0].innerHTML;
for(var i=0;i
scores[i].value=scores[i].value-0+1;
total--;
if(total==0)break;
}
if(i==scores.length-1)i=-1;
};
alert("ok");
说明:将上面的代码放到结帖页面的地址栏里回车就ok了,只用一次,否则会出现负分的情况