87,910
社区成员
发帖
与我相关
我的任务
分享
var list =document.getElementsByClassName('prove');
for(var i=0;i<list.length;i++){
list[i].index=i;
list[i].onclick=function () {
var inde=this.index;
alert(inde);
console.log(list[inde]);
var re=list[inde];
list.remove(re);
}
}
你的list变量在当前的onclick函数中是不存在的,
你可以尝试修改onclick方法为
list[i].onclick=(function () {
return function(){
var inde=this.index;
alert(inde);
console.log(list[inde]);
var re=list[inde];
list.remove(re);
}
})(list);