By | August 11, 2013
Events refer to the actions that are detected by a programming language when you perform a particular task.
Example: the onclick event detected by the programming language when you click the mouse button.
Events are generally used in combination with the function, implying that when an event occurs, it calls a specified function. An event commonly occurs when a user clicks the mouse button , web page is loaded, or from field is changed. Events are handled by a special function, known as event handler, which handles a particular event when the event is triggered.
How to Create an Event handler  :
In the above code OnEvent  refers to the name of an event  followed by an equal sign and the code that executes when the event is triggered.
Let’s do some Exercise :
Working with onclick Event :
The onclick event triggers when you click a particular control, such as button control. Let’s create a webpage to understand the onclick event  :
 Here we defined the onclick event that occurs when we click on ‘Click me ‘ button.
See Output.
Here this alert box appears because of onclick  event and this event occurs when we hit on ‘Click me’ button.
So this is a basic concept of Event,. There are so many Events which are used in JavaScript with HTML. Like some JavaScript  events used in HTML forms are given below :
Some Keyboard Events which are used in HTML:
·         onkeydown
·         onkeypass
·         onkeyup
Some JavaScript mouse events used in HTML
·         onclick
·         ondblclick
·         ondrag*
·         ondragend*
·         ondragenter*
·         ondragleave*
·         ondragover*
·         ondragstart*
·         ondrop
·         onmousedown
·         onmousemove
·         onmouseout
·         onmouseover
·         onmouseup
·         onmousewheel*
·         onscroll*

      *New in HTML5

Etc there are many other Events in JavaScript Which are used in Media elements of HTML and browser. Try with these events yourself. I will discuss these and many other events with working in my Next Post.

  I

  

Leave a Reply

Your email address will not be published. Required fields are marked *