JavaScript Events
In JavaScript, events are actions or occurrences that happen in the browser, usually as a result of user interaction or system-generated events. JavaScript allows you to respond to these events by executing code or functions
Here are some common JavaScript events:
User Interface Events:
Click: Triggered when the user clicks on an element.
DoubleClick: Triggered when the user double-clicks on an element.
MouseOver: Triggered when the mouse pointer enters the area of an element.
MouseOut: Triggered when the mouse pointer leaves the area of an element.
MouseDown: Triggered when the user presses a mouse button over an element.
MouseUp: Triggered when the user releases a mouse button over an element.
MouseMove: Triggered when the user moves the mouse pointer while it is over an element.
KeyDown: Triggered when a key is pressed down.
KeyUp: Triggered when a key is released.
KeyUp: Triggered when a key that produces a character value is pressed down.
Form Events:
Submit: Triggered when a form is submitted.
Change: Triggered when the value of a form element changes (e.g., input field, select box).
Focus: Triggered when an element receives focus.
Blur: Triggered when an element loses focus.
Document and Window Events:
Load: Triggered when a page, or an element, finishes loading.
Resize: Triggered when the browser window is resized.
Scroll: Triggered when an element's scrollbar is scrolled.
Event Handling:
In JavaScript, you can handle events by attaching event listeners to HTML elements. Event listeners are functions that execute when a particular event occurs. You can attach event listeners using the addEventListener() method.