el.addEventListener("click", alert("clicktrack"), false);
When this line is executed, the alert
will be called and return undefined
. To pass the alert code you need to wrap it in a function.
el.addEventListener("click", function() { alert("clicktrack"); }, false);
More Related Contents:
- How to trigger event in JavaScript?
- add event listener on elements created dynamically
- How to check whether dynamically attached event listener exists or not?
- How to remove all listeners in an element? [duplicate]
- Want to add “addEventListener” on multiple elements with same class [duplicate]
- Why Firefox says that window.event is undefined? (call function with added event listener)
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- Getting the ID of the element that fired an event
- How to pass arguments to addEventListener listener function?
- JavaScript, browsers, window close – send an AJAX request or run a script on window closing
- JavaScript global event mechanism
- How do I normalize the CSS3 transition end events across browsers?
- How to make HTML element resizable using pure Javascript?
- Browser event when downloaded file is saved to disk
- Is there a way to get SSL certificate details using JavaScript?
- Intercept all ajax calls?
- How to distinguish mouse “click” and “drag”
- adding multiple event listeners to one element
- Why don’t audio and video events bubble?
- How do I clear this setInterval inside a function?
- html onchange event not working
- How to detect CSS3 resize events
- Code inside DOMContentLoaded event not working
- Javascript change event on input element fires on only losing focus
- Responding to the onmousemove event outside of the browser window in IE
- JavaScript/jQuery event listener on image load IE issues
- onDeviceReady not firing in PhoneGap hello world app
- reactjs event listener beforeunload added but not removed
- Detecting support for a given JavaScript event?
- In web browsers, what’s the difference between onblur and onfocusout?