What is jQuery?

jQuery is a JavaScript library. It 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 HTML/DOM manipulation,CSS manipulation, HTML event methods, Effects and animations, AJAX, Utilities etc

DOM Traversal and Manipulation

// To Replace the content of “.content” class. (CSS Class)

$( “.content” ).html( “Welcome to website…” ) ;

Event Handling

// To Add a click event and show one element.

$( “#button01” ).on( “click”, function( event ) {
$( “#content01” ).show();
});

?>
Ajax

// To Implement Ajax functionality. Current example we can get weather using Ajax functionality.

$.ajax({
url: “/getWeather.php”,
data: {
zipcode: 690573
},
success: function( data ) {
$( “#weather-div” ).html( “” + data + “ degrees” );
}
});