Note
.ready() function called when the page load completely.
For example, if you not use jquery statements inside the .ready() function the statements run before the page load completely.So that It cause some issues on page.To neglect this problem use .ready function.
Example: 1 Jquery with ready() function
Example: 2 Jquery without ready() function
|
Example: 1 Jquery with ready() function
<html>
<head>
<title>HTML-JQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".one").hide();
});
</script>
</head>
<body>
<div class="one">one</div>
<div class="two">two</div>
<div class="three">three</div>
<div class="four">four</div>
</body>
</html>
|
Example: 2 Jquery without ready() function
<html>
<head>
<title>HTML-JQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function () {
$(".one").hide();
});
</script>
</head>
<body>
<div class="one">one</div>
<div class="two">two</div>
<div class="three">three</div>
<div class="four">four</div>
</body>
</html>
|
Example: 1 Demo
|
Example: 2 Demo
|