javascript - Add a default parameter AddEventListener function call -


i creating js function takes id specific values , add event listener of them. of them listen click event , when it's clicked should call function has 2 arguments. these parameter values unique each id.

for (var = 0; < globalarray.length; i+=3){   document.getelementbyid(globalarray[i]).addeventlistener("click",   loadtable(globalarray[i+1], globalarray[i+2]), false); } 

here have globalarray first element id , second , third ones first , second arguments respectively. how can thing. each time calls, not adding eventlistener.

but not call function, adds event listeners gets ready trigger 'some' function whenever "demobutton" button clicked.

document.getelementbyid("demobutton").addeventlistener("click", some); 

use anonymous function when called call loadtable function respective arguments.

for (var = 0; < globalarray.length; i+=3){   document.getelementbyid(globalarray[i]).addeventlistener("click", function(){    loadtable(globalarray[i+1], globalarray[i+2])  }, false); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -