Introduction of JQuery
How to use JQuery, How to add JQuery in my site, How to work with JQuery
What is JQuery
jQuery is lightweight JavaScript library that makes it faster and easier to build JavaScript for WebPages. jQuery theme is "Write less Do more". Absolutely you can write a single line of code to achieve what would have taken 10-20 lines of classic JavaScript code. jQuery was released in January 2006 at BarCamp NYC by John Resig.
How jQuery Works
Befor working with JQuery you must load the JQuery library in your web page. There are two options available for do that.- Load your own copy of JQuery library
- Load JQuery library from http://jquery.com
Note: Your jquery.js file must be in the same directory as your HTML file
Ex:
<html>
<head>
<title>JQuery Example</title>
</head>
<body>
<script src="jquery.js"></script>
<script>
</script>
</body>
</html>
<head>
<title>JQuery Example</title>
</head>
<body>
<script src="jquery.js"></script>
<script>
</script>
</body>
</html>
In the second option you must point the script src to "http://code.jquery.com/jquery-1.5.min.js"
Ex:
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
How to check is JQuery working
After that you followed one of given option you can add following statement in between script section of your HTML file for check is JQuery works fine
$(document).ready(function(){
alert("congratulation! You are ready to work with JQuery");
});
alert("congratulation! You are ready to work with JQuery");
});
Ex:
<html>
<head>
<title>JQuery Example</title>
</head>
<body>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
alert("congratulation! You are ready to work with JQuery");
});
</script>
</body>
</html>
<head>
<title>JQuery Example</title>
</head>
<body>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
alert("congratulation! You are ready to work with JQuery");
});
</script>
</body>
</html>
If JQuery library does not load correctly you will detect an error as "$ is not defined"