2
Why click is not invoked?
$elemento.addEventListener('click', click, true);
var click = () => { ... };
2
Why click is not invoked?
$elemento.addEventListener('click', click, true);
var click = () => { ... };
4
You must declare the variable with its function before trying to use it...
document.addEventListener('DOMContentLoaded', function() {
var click = () => {
alert("Clicou");
};
document.getElementById("test").addEventListener("click", click, true);
}, false);
<input type="button" value="test" id="test">
Browser other questions tagged javascript javascript-events
You are not signed in. Login or sign up in order to post.
I get it. However, I thought that when declaring the variable that stores the anonymous function with var, it would be of global scope being accessed from any part of code even though it was declared before use. Thank you
– Jonatas Bueno do Livramento