Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Hour 4. Understanding Client-Side Scripting > Event Handling with JavaScript

Event Handling with JavaScript

The dynamic content or style modifications happen when the user triggers an action on a web page. This is achieved through events on the HTML elements. Many events can occur on a web page—for example, when you are moving the mouse over an HTML element, an onmouseover event is fired. When a button is clicked, an onclick event is fired. You can have these events handled through JavaScript code. The good thing is all the basic events are handled quite similarly among different browsers. Here is a small example showcasing the onclick event and its handler:

<input type=button id=btnDisplay value=Display
onclick=alert('Button click event is fired !');/>


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint