Write a note on JavaScript events.
SOLUTION....
πΉ JavaScript Events
In JavaScript, an event is an action or occurrence that happens in the browser, which the program can respond to. Events are usually triggered by user interactions such as clicking a button, typing text, or moving the mouse, but they can also be triggered automatically (like page load or errors).
Events help make web pages interactive and dynamic, because JavaScript code can be executed when a specific event occurs.
πΉ Common Types of JavaScript Events
Mouse Events
Triggered by actions performed with a mouse.
Examples:
onclick
β when an element is clickedondblclick
β when double-clickedonmouseover
β when the mouse pointer is moved over an elementonmouseout
β when the pointer leaves the element
Keyboard Events
Triggered when the user presses or releases keys on the keyboard.
Examples:
onkeydown
β when a key is pressedonkeyup
β when a key is releasedonkeypress
β when a key is pressed and held
Form Events
Triggered when interacting with HTML forms.
Examples:
onfocus
β when an input field is focusedonblur
β when the focus leaves an input fieldonsubmit
β when a form is submittedonchange
β when the value of a form field changes
Window/Document Events
Triggered by actions related to the browser window or the document.
Examples:
onload
β when a page or image has fully loadedonresize
β when the window is resizedonscroll
β when the page is scrolled
πΉ Example of JavaScript Events
