JQuery Documentation
JQuery Documentation
JQuery Overview
jQuery is a popular library that simplifies the process of interacting with documents, handling
events, creating animations, and making AJAX requests. Here’s a summary of the key features and
methods I explored
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
jQuery Syntax
The basic syntax for jQuery is quite straightforward. It follows the pattern $(selector).action(), where
$(selector) is used to select elements and .action() specifies what to do with those elements. For
$(document).ready(function() {
$("p").text("Hello, World!");
});
Selectors
jQuery selectors are similar to CSS selectors and are used to find elements within the DOM. Common
selectors include:
$("#myId").css("color", "blue");
$(".myClass").hide();
Akshay P
Handling Events
jQuery makes it easy to handle various events such as clicks, mouse movements, and keyboard
inputs. Some commonly used event methods are:
$("button").click(function() {
alert("Button clicked!");
});
$("#myDiv").fadeIn("slow");
$("#myDiv").slideUp();
$("#myDiv").css("color", "red").slideUp(2000).slideDown(2000);
Akshay P
$("#myDiv").("<p>New content</p>");
$("#myDiv").addClass("highlight");
$("#myDiv").find(".child");
Akshay P
AJAX Requests
jQuery simplifies making AJAX requests:
$.ajax({
url: "example.com/api",
method: "GET",
success: function(data) {
console.log(data);
});
Miscellaneous Features
noConflict(): This method allows you to release control of the $ variable to avoid conflicts
with other libraries.
Filters: Methods like .filter(), .not(), and .is() help in selecting elements based on specific
criteria.
Example:
jQuery.noConflict();
$("p").filter(".special");
This summary covers the essential aspects of jQuery, providing a clear understanding of how to use
the library effectively for various web development tasks.