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 Tag: jQuery, javascript, event handler, event Category: JavaScript Post : March 20th 2008 Read: 2,387 blog comments powered by Disqus |