Hi friends , in this article I will explain about .ready()
method in JQuery with example.
I already explained in the previous article What is JQUERY | JQuery Tutorial | JQuery syntaxes. See once if you want to know.
JQuery:
- jQuery is a JavaScript Library.
- It simplifies the JavaScript programming.
- jQuery is a lightweight "write less, do more" JavaScript library.
- It is a library of JavaScript functions.
We have to use the below line to execute the JQuery
functions, jquery.js is mandatory. Because all Jquery functions or methods are
included in the JQuery.js library.
<script type="text/javascript"
src="jquery.js"></script>
|
JQuery Ready() Method:
The .ready ()
method is generally incompatible with the <body onload="">
attribute.
If load must
be used, either do not use .ready () or use jQuery's .load() method to attach load event handlers
to the window or to more specific items, like images.
Use ready()
to make a function available after the document has been loaded:
All three of
the following syntaxes are equivalent:
$(document).ready(handler)
$().ready(handler)
//(this is not recommended)
$(handler)
|
Syntax for
JQuery Ready method is
$(document).ready(function() {
// write the code
like click function for .ready() called.
});
|
The following
program will explain the how the ready function will work.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Aspdotnet-Roja</title>
<script type="text/javascript" src="jquery.js"></script>
<script type ="text/javascript" language ="javascript">
$(document).ready(function(){alert("Enter into the
Ready function.")
$('p').text("Click me !!!!!!! i will disappear"); // assigning data to p
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p></p>
</div>
</form>
</body>
</html>
|
In the above
example when we execute the above page it will automatically displays the ‘p’
as Click me !!!!!!! i will disappear.
Actually
ready () method in JQuery is equal to the load () method in body tag.
I think you like my blog Aspdotnet-Roja why are waiting following me on facebook fan page Aspdotnet-roja
No comments:
Post a Comment