/*
DOM [Events]
- Use Events On HTML
- Use Events On JS
--- onclick
--- oncontextmenu
--- onmouseenter
--- onmouseleave
--- onload
--- onscroll
--- onresize
--- onfocus
--- onblur
--- onsubmit
*/
let myBtn = document.getElementById("btn");
myBtn.onmouseleave = function () {
console.log("Clicked");
};
window.onresize = function () {
console.log("Scroll");
};
// An event is triggered when a user clicks on the #button element,
// which then sets the #button element's background-color to blue.
$('#button').on('click', event => {
$(event.currentTarget).css('background-color', 'blue');
});
<!DOCTYPE html>
<html>
<body>
<h1 onclick="this.innerHTML = 'Ooops!'">Click on this text!</h1>
</body>
</html>