Document Ready Event | jQuery

Hello All,

This blog is about Document Ready Event in jQuery,

Document Ready Event :
The document ready event is allowed to perform the functions once the page(DOM) gets loaded. Because in some cases the page takes time to get load.

Syntax:
$(document).ready();

Similarly There is also an another event called Windows load

Windows Load Event :
This event is also works like DOM.
The difference is, will allows to perform the function once the entire page (including images & iframes not only DOM) get loaded.

Syntax:
$(windows).load();

E.g.:
1. At .php file:

<!doctype html>
<html lang ="en">
<head>
<meta charset="utf-8">
<title>Document Ready Event</title>
</head>
<link rel="stylesheet" type="text/css" href="css/style.css"> 
Welcome to Geeks.gallery
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="js/jQuery.js"></script>


</body>
</html>

2. At .js file:

$(document).ready(function() {
alert('Document is ready');
} );

o/p:

Thanks for Reading !!!

Leave a Reply

Your email address will not be published. Required fields are marked *