- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Event Object
JavaScript Events
JavaScript Event Object
Every handler receives an event object describing what happened.
The browser passes it in automatically as the first argument.
It is usually called event or just e.
Example
Example
javascript
document.body.innerHTML = '<button id="btn">Go</button>';
document.getElementById("btn").addEventListener("click", function (event) {
console.log(event.type);
});
document.getElementById("btn").click();