Open In App

What is jQuery ?

What is jQuery?

jQuery is a fast, small, and feature-rich JavaScript library designed to simplify client-side scripting of HTML. It simplifies the process of handling events, performing animations, and manipulating HTML documents. jQuery provides a set of easy-to-use methods and utilities that abstract many complex tasks, making JavaScript coding more efficient and less cumbersome.



History of jQuery

jQuery was created by John Resig in 2006 while he was working at BarCamp NYC. The initial purpose of jQuery was to provide a cross-browser JavaScript library that simplifies the process of interacting with HTML elements and handling events. Since its release, jQuery has evolved rapidly, with regular updates and improvements to its functionality and performance.

Different ways of including jQuery in HTML

Direct Download:

You can download the jQuery library from the official website (https://jquery.com/) and include it in your HTML file using the <script> tag.



CDN (Content Delivery Network):

You can include jQuery directly from a CDN, such as Google CDN or jQuery’s own CDN. This method offers the advantage of faster loading times and better caching.

CDN link:

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Package Manager:

If you’re using a package manager like npm or Yarn, you can install jQuery as a dependency and include it in your project.

command:

npm install jQuery

Example: In this example, when the button is clicked, the paragraph element (<p>) is toggled between visible and hidden states.

<!DOCTYPE html>
<html>
<head>
<title>jQuery Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>

<h2>jQuery Example</h2>
<button>Toggle Paragraph</button>
<p>This is a paragraph with some text.</p>

</body>
</html>

Output:

Application of jQuery

Advantages of jQuery

Limitations of jQuery

Conclusion

In summary, jQuery is a JavaScript library that simplifies client-side scripting of HTML. It offers numerous advantages, such as simplicity and cross-browser compatibility, but also has limitations, including file size and dependency. Understanding these factors is important for making informed decisions about its usage in web development projects.

Article Tags :