Document Ready Method


In this lesson we discuss about $(document).ready(function(){});Method. Do you remember we are discuss about Onload Method of java script in previous lesson, So these both are same method. Use of document.ready method is whenever our JQuery is not run properly or when we use jQuery on top of the html page than we use jQuery document.ready method for run our code properly, by using this jquery read any java script after download the all contents.In other ways we can say we can use java script from anywhere in html page by using document.ready method. let see an example.

Image

In the above example first we create a class red for modify color red the elements where we want to use this. Than we select jQuery or reference the jQuery. Than we use our custom script tags. We create document.ready function and select first child of list item for modify color of first child of list items.

New way to use ready method by refer jQuery to a function. let see

Image

In above way we just pass jQuery to a function. By giving a reference to a function where we creating our code than jQuery returns as document.ready function.


Wconcert India © 2015   ·   All Rights Reserved

Free Web Hosting