I am using the function, to add each li into each function, using addEventListener. According to me, on click on each li, should call each separate function. how can i add the li’s separately each functions? any one can help me..?
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');
}
}
Use an array to store your functions,
Then add the event listeners as,
See an example.