top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is Difference between $(document).ready() vs window.onload()?

0 votes
154 views
What is Difference between $(document).ready() vs window.onload()?
posted Jan 17, 2018 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

$(document).ready()

jQuery document.ready will execute our code when the HTML is all ready, but before images and other resources have finished.

$(document).ready(function(){
//write your code here;

})

window.onload()

window.onload() runs after everything has finished loading including images and scripts, but usually not stylesheets. Use this for code when page wouldn't change anymore.

window.onload = function() {
  init();
 doSomethingElse();
};

Hopefully this will help you. Thanks.

answer Feb 24, 2018 by Vishi Gulati
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...