jQuery: Using Event Handler


JQuery Introduction Step By Step Tutorial - Part 4:We know, JavaScript have event handlers. Many handlers are available for user-initiated events, such as mouse clicks, key presses, load. In this post, we will see how to apply it.

In this practice, we use onload event at body. Like this:

<body onload="lyricstyle();">

For this purpose, we must modify our myjs.js. Modify it become like this:

// JavaScript Document
$(document).ready();

function lyricstyle(){
  $('.lyric-text').addClass('lyric-full');
}				  

We create new function: lyricstyle(). We don't put in $(document).ready(). What is impact? This causes our code to run after the page is completely loaded.



Series this article:
jQuery: Introduction
jQuery: Installation
jQuery: My First Code
jQuery: Using Event Handler

Bookmark and Share Tag: jQuery, javascript, event handler, event Category: JavaScript Post : March 20th 2008 Read: 20,810

advertisements


blog comments powered by Disqus