What is the difference between $(window).load and $(document).ready function in jQuery?

In This blog, we are going to learn, Difference between $(window).load and $(document).ready function in jQuery?

Both methods seem too similar. The ready() method is used to make a function available after the document is loaded. The window. load() event is fired when the whole web page has completed loading.

$(window).load()

The window.load() event is fired when the whole web page has completed loading.The code which gets included inside $( window ).on( “load”, function() { … }) runs only once the entire page is ready (not only DOM).

for example :
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   $("img").load(function(){
     alert("Image successfully loaded.");
   });
});
</script>
</head>
<body>

<img src="" alt="img" width="280" height="236">


note: please add src in image.

</body>
</html>

$(document).ready()

$(document).ready() events do the same.The ready() method is used to make a function available after the document is loaded. Whatever code you write inside the $( document ).ready() method will run once the page DOM is ready to execute JavaScript code.

for example:
<html>

   <head>
      <title>my class</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

      <script>
         $(document).ready(function() {
           $("div").click(function() {
              alert("Hello !");
           });
         });
      </script>
   </head>
   
   <body>
      <div id = "myjob">
         Click on this to see a dialogue box.
      </div>
   </body>
</html>

I hope after reading this article you will be able to understand, Thanks for following this Blog.

expoundsofttechsolution

What is the difference between $(window).load and $(document).ready function in jQuery?

How to add a logo to email templates?