<body onload=""> or
window.onload, it provides similar hooks for user-initiated events such as mouse clicks (
onclick), form fields being modified (
onchange), and windows changing size (
onresize). When assigned directly to elements in the DOM, these hooks have similar drawbacks to the ones we outlined for
onload. Therefore, jQuery offers an improved way of handling these events as well.
To illustrate some event handling techniques, suppose we wish to have a single page rendered in several different styles based on user input. We will allow ...