JS Events
M2-R5.1 · Chapter 6: JavaScript and Angular JS · 1 min read
JavaScript Events – Notes
What is an Event?
An event is an action or occurrence in the browser that JavaScript can respond to.
Examples: clicking a button, moving the mouse, typing in a field, page loading, etc.
Types of JavaScript Events
1.) Mouse Events
Triggered by mouse actions.
Example:
<button onclick="alert('Button Clicked!')">Click Me</button>
2.) Keyboard Events
Triggered by keyboard actions.
3.) Form Events
Used in forms.
Example:
<input type="text" onfocus="console.log('Input focused')" />
4.) Window / Document Events
Example:
<body onload="console.log('Page Loaded')">