0
我正在使用该函数,使用addEventListener将每个li添加到每个函数中。据我所知,每点击一下,都应该调用各个单独的功能。我怎样才能分别添加李的每个功能?任何人都可以帮助我..?如何将eventListener添加到每个单独的函数中?
window.onload = function(){
var myLi = document.getElementById('ul').getElementsByTagName('li');
for(i=0;i<=myLi.length;i++){
myLi[i].addEventListener('click','call'+[i],false);
}
function call(){
alert('function one called');
}
function call2(){
alert('function two called');
}
function call3(){
alert('function three called');
}
}
callN()函数有什么不同?现在对我来说听起来像你最好重新考虑代码,所以它不需要X个函数来正确运行。 – Stephen 2011-03-03 05:16:57