Note: The only library available today that meets the needs of both designer types and programmer types is jQuery.
Some of the key points which supports the answer for why to use jQuery:
- It is incredibly popular, which is to say it has a large community of users and a healthy amount of contributors who participate as developers and evangelists.
- It normalizes the differences between web browsers so that you don’t have to.
- It is intentionally a lightweight footprint with a simple yet clever plugin architecture.
- Its repository of plugins is vast and has seen steady growth since jQuery’s release.
jQuery is widely famous with its philosophy of “Write less, do more.” This philosophy can be further elaborated as three concepts:
- Finding some elements (via CSS selectors) and doing something with them (via jQuery methods) i.e. locate a set of elements in the DOM, and then do something with that set of elements.
- Chaining multiple jQuery methods on a set of elements
- Using the jQuery wrapper and implicit iteration
Using jQuery (JS) library on HTML page
There are several ways to start using jQuery on your web site.
- Use the Google-hosted/ Microsoft-hosted content delivery network (CDN) to include a version of jQuery.
- Download own version of jQuery from jQuery.com and host it on own server or local filesystem.
Note:All jQuery methods are inside a document ready event to prevent any jQuery code from running before the document is finished loading (is ready).
Basic syntax for any jQuery function is:
- A $ sign is to define/access jQuery
- A (selector) is to “query (or find)” HTML elements in html page
- A jQuery action() is the action to be performed on the selected element(s)
This example explain a case where a user clicks on a button and the elements with class = “gfg” will be hidden as an effect of that.
- Large development community
- It has a good and comprehensive documentation
- JQuery lets users develop Ajax templates with ease, Ajax enables a sleeker interface where actions can be performed on pages without requiring the entire page to be reloaded.
- Being Light weight and a powerful chaining capabilities makes jQuery more strong.
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- JQuery | Multiple ID selectors
- jQuery | :input Selector
- jQuery | prepend() with Examples
- jQuery | dblclick() with Examples
- jQuery | offset() with Examples
- How to find the parent class name with known class in jQuery ?
- jQuery | :nth-of-type() Selector
- How to Design Color Picker using jQuery UI ?
- jQuery | children() with Examples
- jQuery UI | position() Method
- jQuery | Hide/Show, Toggle and Fading methods with Examples
- JQuery | parseHTML() method
- jQuery | focusin() with Examples
- jQuery | Animation, Slide methods with Examples
- jQuery | Selectors and Event Methods
- jQuery | change() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.