jQuery Document Ready function

Posted in: jQuery No Comments

We want our jQery codes to run / execute only after DOM is ready. Like this we do not want complete page to load but only wants DOM to be ready before running any jQuery codes. This also ensures that we are not executing any code before the DOM is ready. This confirms that any elements being accessed by jQuery codes are actually in existence, so it won’t return any errors.

Using the document.ready() function is really easy. You can use any below format for this:

1. This is the most common way.

$(document).ready(function() {
  // all jQuery code goes here

2. This is same as first one with lesser words.

  // all jQuery code goes here

3. Below method prevent conflicts with other javascript frameworks.

jQuery(document).ready(function($) {
  // all jQuery code goes here

About the Author

Name: Ravi Shekhar
I love learning and sharing web stuffs.

Share this post

Twitter Facebook Google Buzz Digg StumbleUpon Delicious Technorati

Leave a Reply