Saturday 11 April 2015

How can I check DOM is ready in jQuery


How can I check DOM is ready in jQuery

Question: What is DOM?
The Document Object Model (DOM), is a model for representing and interacting with an XML, XHTML and HTML document.


Question: What is meaning of DOM is ready?
DOM is ready means html, images, css and java-Script are loaded fully.


Question: Why need to check if DOM is ready OR NOT?
Some times, we need to do the some modification in html tags like p,div and image etc.
We can change the DOM only after if DOM is loaded.


Following are 3 methods to check DOM() is fully loaded?
Method 1:
 jQuery(document).ready(function(){ 
      //consol.log('DOM IS FULLY loaded');

  });

Method 2:
$(function(){
  //consol.log('DOM IS FULLY loaded');
});  

Method 3:
if ( jQuery.isReady ) {  
    //consol.log('DOM IS FULLY loaded');
}