- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Mouse Events
JavaScript Events
JavaScript Mouse Events
Mouse events report clicks, movement and hovering over an element.
click is by far the most used, but there are several others.
Each one gives coordinates telling you where the pointer was.
Example
Example
javascript
document.body.innerHTML = '<button id="btn">Go</button>';
document.getElementById("btn").addEventListener("click", function () {
console.log("clicked");
});
document.getElementById("btn").click();