jQuery Basic Concepts

The jQuery library offers a range of user-friendly techniques and functions that greatly facilitate the development of feature-rich applications. Its popularity is attributed to the simplicity of its functions, making it highly favored among developers. Notably, jQuery finds applicability across a spectrum of web-based applications, irrespective of the underlying technology, seamlessly integrating with various web programming languages like ASP, PHP, JSP, CGI, and Servlets.

The jQuery syntax is tailor-made for selecting HTML elements and performing some action on the element(s).

$ Sign

The $ symbol is essentially a function within jQuery, serving as an alias for the actual function named jQuery(). This shorthand can be expressed as either $() or jQuery(). This decision was made due to the convenience it offers — instead of typing out the six letters of "jQuery", developers can use the single $ character, which is a valid variable name. This substitution allows $() to act as a condensed version of JavaScript's findElementById(), findElementByClass(), and similar functions. By supplying a CSS-like selector, $() efficiently returns all matching elements, contributing to the framework's streamlined usability.

Basic syntax is:


A dollar sign to define jQuery a (selector) to "query (or find)" HTML elements. A jQuery action() to be performed on the element(s).

Selectors in jQuery operate in a manner similar to CSS selectors, requiring you to specify them in a comparable fashion. When referring to HTML elements, you can use the element's tag name directly, just as you would in CSS. This seamless integration with CSS-style selectors simplifies the process of targeting and manipulating HTML elements using jQuery. See the following examples:

  1. $("a") - all anchor tags
  2. $("p") - all paragraph tags
  3. $("p.main") - all paragraph tags with a class of main

When referencing class names, you must specify the period (.) before the class name as in the following example:

$(".main") // all elements with the class name of main.

Also, when referencing IDs, you must specify the # before the ID name:

$("#main") // the element with the ID of main.

jQuery selectors

Selectors in jQuery are text strings designed to pinpoint specific HTML elements within a webpage. The syntax of selectors is intuitive and user-friendly, making it straightforward to comprehend and utilize. These selectors empower developers to efficiently choose an HTML element and subsequently execute various actions or events on the selected element with ease.

  1. Based on the element name : $("a")
  2. Based on the elements ID attribute : $("#ID")
  3. Based on the elements class attribute : $("className")

jQuery events

jQuery events occur when the following situations occur

  1. Moving a mouse over an element
  2. Submitting a form
  3. Clicking on an element

These events allow programmers to create interactive user interfaces.

jQuery Effects and Animations

jQuery boasts a selection of innate effects that can be seamlessly integrated with nominal coding effort. To facilitate more nuanced personalization, our attention turns to animations, empowering developers to elegantly animate a multitude of visual attributes intrinsic to HTML elements.


jQuery encompasses fundamental concepts such as built-in effects for swift implementation with minimal code and the more intricate field of custom animations, which empower developers to animate diverse visual aspects of HTML elements. This versatile library offers an array of tools to enhance interactivity and aesthetics within web development.