jQuery is a lightweight, "write less, do more", JavaScript library.
The purpose of jQuery is to make it much easier to use JavaScript on your website.
jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation
The jQuery library contains the following features:
There are lots of other JavaScript frameworks out there, but jQuery seems to be the most popular, and also the most extendable
Many of the biggest companies on the Web use jQuery, such as:
Most popular Javascript library are as follows:
Most popular Javascript frameworks are as follows:
There are two versions of jQuery available for downloading:
There are several ways to start using jQuery on your web site. You can:
The jQuery library is a single JavaScript file, and you reference it with the HTML <script > tag (notice that the <script > tag should be inside the <head > section):
<head> <script src="jquery-3.4.0.min.js"></script> </head>
Can also add from Google CND
<head> <https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> </head>
Can also add from Microsoft CDN
<head> <https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.0.min.js"></script> </head>
Basic syntax is: $(selector).action()
Example:
$(this).hide() - hides the current element.
$("p").hide() - hides all <p> elements.
$(".test").hide() - hides all elements with class="test".
$("#test").hide() - hides the element with id="test".
You might have noticed that all jQuery methods in our examples, are inside a document ready event:
$(document).ready(function(){ // jQuery methods go here... });
This is to prevent any jQuery code from running before the document is finished loading (is ready)
It is good practice to wait for the document to be fully loaded and ready before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section.
Here are some examples of actions that can fail if methods are run before the document is fully loaded:
The jQuery team has also created an even shorter method for the document ready event:
$(function(){ // jQuery methods go here... });
Total : 20975
Today :29
Today Visit Country :