jQuery is a library of JavaScript functions that facilitates interacting with HTML documents and manipulating them. The library is designed to reduce the time and effort spent on writing code and achieving cross-browser compatibility, while at the same time taking full advantage of what JavaScript offers to build interactive and responsive web applications.
The general workflow of using jQuery consists of two steps:
Select an HTML element or a group of elements to work on
Apply a jQuery method to the selected group
jQuery provides a simple approach to select elements; it works by passing a CSS selector string to a function called $
. Here are some examples to illustrate the usage of this function:
If you want to select all anchor (
<a>
) elements on a page, you can use the following function call:$("a")
If you want to select anchor elements which have the
.title
CSS class, use$("a.title")
To select an element whose ID is
#nav
, you can use...