ClickOnChris

Christopher G Johnson: programmer, entrepreneur, gamer

A Better Window.onLoad with jQuery

without comments

I have recently come to discover the javascript library jQuery. My favorite feature is the window.onLoad replacement, which is actually faster than window.onLoad and can be used multiple times in one document.

<span style="color: #008000;">  $(document).ready(function(){
    // Your code here...
  });</span>

Any code in the Your code here.. block will execute as soon as the page is loaded. This is useful for referencing DOM elements which would have been “undefined” before the page was fully loaded by the browser.

Post to Twitter

Fork me on GitHub

Written by clickonchris

December 23rd, 2008 at 9:02 pm

Leave a Reply

Twitter links powered by Tweet This v1.8.2, a WordPress plugin for Twitter.

Switch to our mobile site