Saturday, 20 August 2011

Javascript: HTML Events

Hi Everyone,

HTML events can be detected using Javascript. For example, a mouse click or a user selection on a dropdown. We can assign functions to these events and we can attach and detach events as well. Let me further explain the types of events that we use.


onblur: It is triggered when a HTML element has lost focus. For example, you keyed in something in the textbox and then u click outside the textbox. Another example is pressing the tab button on the keyboard.


onchange: An onchange event is triggered when user selects an item from the dropdown. It can be used to handle how a website displays and hides certain fields.


onclick: It is triggered by a mouse click. It is used on radio buttons, buttons or a link on a website.


ondblclick: It is triggered when a mouse button is double clicked


onfocus: It is triggered when a HTML event is being focused.


onkeydown: It is triggered when a key is pressed on the keyboard. It can be used to assist users to enter numeric values only or to avoid users from entering special characters.


onkeyup: It is triggered when a key is lifted up. It is the event after you pressed a key on the keyboard.


onmousedown: It is triggered when a mouse button is pressed


onmouseup: It is triggered when a mouse button is released


That concludes the HTML events for the day.


References:


1. HTML DOM Event Object: http://www.w3schools.com/jsref/dom_obj_event.asp

Cheers,

Rogerkoo

No comments:

Post a Comment