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.
onchange | script | Triggers when an element change |
Onabort | script | Triggers on an abort event |
onblur | script | Triggers when the window loses focus |
onkeydown | script | Triggers when a key is pressed |
onkeypress | script | Triggers when a key is pressed and released |
onfocus | script | Triggers when the window gets focus |
onload | script | Triggers when the document loads |
onmousedown | script | Triggers when a mouse button is pressed |
onmouseout | script | Triggers when the mouse pointer moves out of an element |
onselect | script | Triggers when an element is selected |
onunload | script | Triggers when the user leaves the document |
No comments:
Post a Comment