What is jQuery
jQuery is a JavaScript Library which simplifies JavaScript programming, HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
Your first jQuery code
Lets see an example which will popup an alert while loading the page using jQuery.
1 2 3 4 5 6 7 8 9 10 |
<html> <script type="text/javascript" src="script/jquery-1.8.2.js"> </script> <script type="text/javascript"> window.jQuery("document").ready(function(){ alert("This is from j2eereference.com"); }) </script> <body> </body> </html> |
Here you can notice that we have included a java script file – jquery-1.8.2.js , Which provides many features. You can download this js file from jQuery website.
jQuery provides a shortcut ‘$ ‘ for window.jQuery(“document”).ready , By which we can rewrite the code as below.
1 2 3 4 5 6 7 8 9 10 |
<html> <script type="text/javascript" src="script/jquery-1.8.2.js"> </script> <script type="text/javascript"> $(function(){ alert("This is from j2eereference.com"); }) </script> <body> </body> </html> |
Leave a Reply