0
addEventListener
I can do something like this: var el = document.querySelector('#el'); var f = function(){ alert('test') } el.onclick = f;// so i can do it with any var. How can i do it with addEventListener?
5 odpowiedzi
+ 4
You can do this:
el.addEventListener('click', f);
addEventListener takes two parameters, first should be the event name in string and another should be the function to be called.
+ 2
x.addEventListener("
click
", func,
true
);
0
0
Drag and drop from the options below to handle the click event and use capturing propagation.
x.addEventListener(" ____ ", func,___ );
0
x.addEventListener(" click ", func,true);