December 2013
Intermediate to advanced
384 pages
9h 54m
English
function clickHandler(e, data){ (Event Handler Code) } ... document.getElementById("div1").addEventListener('click', function(e){ eventHandler(e,"data"); },false);
You can also dynamically add and remove event handlers to DOM objects inside JavaScript code. To add an event handler in JavaScript, simply call addEventListener() on the DOM object.
The addEventListener() function takes three parameters. The first is the event type (event types are defined in Table 6.1), a function to call and a boolean that specifies true if the handler should be called during the capturing phase and the bubbling phase or false if the handler should be called only during the bubbling ...
Read now
Unlock full access