What is jQuery?
jQuery is “write less, do more” open source Javascript library.
Specialized for changing web page documents on the fly.
jQuery makes it easy to add action and interactivity to any web page.
jQuery makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
jQuery is the core library. jQueryUI is built on top of it. If you use jQueryUI, you must also include jQuery.
Importance of jQuery?
Open Source.
jQuery is SEO friendly and CSS3 compliant.
Browser Compatibility i.e.; Works for all browsers.
jQuery is very small, clean code that won’t bog down the loading time of web pages
Highly Documented.There’s a low learning curve. Since it’s based on plain old JavaScript, developers can learn jQuery fast.
Web page elements display even if JavaScript is disabled in the browser.
Simplifies AJAX.
It is extensible – jQuery can be extended to implement customized behavior.
History of jQuery
Developed by John Resig.
Initial Release – 2006
Current Version – 3.1.1
Main site: https://jquery.com/
Basic Structure of jQery
<script type = “text/javascript”>
//jQuery detects this state of readiness for you.
$( document ).ready() method will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute.
$(document).ready(function(){
document.write(“Hello, World!”);// to print a string we will use document.write(); method
});
</script>
File Extension of jQuery
filename.js
Comment Line in jQuery
Single line comment is done using //
Multi- line comment start with /* and end with */.
Variable Declaration
In jQuery, you can declare variable in two styles.
- $.name = “value”;
2. var variable_name = “value”;