Copyright © tutorialspoint.com

# jQuery - ready( fn ) Method

# Description:

The ready( fn ) method binds a function to be executed whenever the DOM is ready to be traversed and manipulated.

This method is a replacement for using window.onload

# Syntax:

Here is the simple syntax to use this method:

    selector.ready( fn )

## Parameters:

Here is the description of all the parameters used by this method:

- fn: The function to be executed when the DOM is ready.

# Example:

Following is a simple example a simple showing the usage of this method:

    <html>
    <head>
    <title>the title</title>
       <script type="text/javascript"
       src="/jquery/jquery-1.3.2.min.js"></script>
       <script type="text/javascript" language="javascript">

       $(document).ready(function() {
          $("div").text("The DOM is now loaded...");
       });

       </script>
       <style>
          .div{ margin:10px;padding:12px;
                 border:2px solid #666;
                 width:200px;
               }
      </style>
    </head>
    <body>
       <div class="div" style="background-color:blue;"></div>
    </body>
    </html>

To understand it in better way you can Try it yourself.

Copyright © tutorialspoint.com