index的用法

示例1:window.onload=function(){
var oPf=document.getElementById('pingfen');
var aLi=oPf.getElementsByTagName('li');
var i=0;

for(i=0;i<aLi.length;i++){
aLi[i].index=i;
aLi[i].onmouseover=function(){
for(i=0;i<aLi.length;i++){
if(i<=this.index)
{
aLi[i].style.background="url(star.gif) no-repeat 0 -29px";
}
else
{
aLi[i].style.background="url(star.gif) no-repeat 0 0";
}
}
};

aLi[i].onmousedown=function ()
{
alert('提交成功:'+(this.index+1)+'分');
};
}
};

posted @ 2015-08-17 22:26  远方小镇  阅读(354)  评论(0编辑  收藏  举报