Sunday, December 9, 2018

XII SC IT NOTES ON EVENTS IN JAVASCRIPT

What is an Event ?

JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page.
When the page loads, it is called an event. When the user clicks a button, that click too is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc.
Developers can use these events to execute JavaScript coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated, and virtually any other type of response imaginable.
Events are a part of the Document Object Model (DOM) Level 3 and every HTML element contains a set of events which can trigger JavaScript Code.

onclick Event Type

This is the most frequently used event type which occurs when a user clicks the left button of his mouse. You can put your validation, warning etc., against this event type.

onsubmit Event type

onsubmit is an event that occurs when you try to submit a form. You can put your form validation against this event type.

onmouseover and onmouseout

These two event types will help you create nice effects with images or even with text as well. The onmouseover event triggers when you bring your mouse over any element and the onmouseout triggers when you move your mouse out from that element.

onchangescriptTriggers when an element change
OnabortscriptTriggers on an abort event
onblurscriptTriggers when the window loses focus
onkeydownscriptTriggers when a key is pressed
onkeypressscriptTriggers when a key is pressed and released
onfocusscriptTriggers when the window gets focus
onloadscriptTriggers when the document loads
onmousedownscriptTriggers when a mouse button is pressed
onmouseoutscriptTriggers when the mouse pointer moves out of an element
onselectscriptTriggers when an element is selected
onunloadscriptTriggers when the user leaves the document

No comments:

Post a Comment