document.ready()
function is different from body onload()
function for several reasons:
- We can have more than one
document.ready()
function in a page where we can have only one bodyonload
function. document.ready()
function is called as soon as DOM is loaded wherebody.onload()
function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.