JQuery: onload event example

This page uses JQuery to handle the page onload event. The alert box is triggered by JQuery's $(document).ready() function

If you recall, in a previous example, we used the "onload" attribute of the <body> tag to detect the onload event without JQuery.

This technique using JQuery is better because it does not require any changes to the XHTML code - all the behaviors are coded in Javascript, which means the code responsible for behaviors is clearly separated from the markup code.