jQuery

jQuery is a lightweight, "write less, do more", JavaScript library.

Features:

  • HTML/DOM manipulation

  • CSS manipulation

  • HTML event methods

  • Effects and animations

  • AJAX

  • Utilities

Usage

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

Syntax

$(selector).action()
  • A $ sign to define/access jQuery

  • A (selector) to "query (or find)" HTML elements

  • A jQuery action() to be performed on the element(s)

Selectors

jQuery selectors allow you to select and manipulate HTML element(s).

jQuery selectors are used to "find" (or select) HTML elements based on their name, id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.

  • The jQuery element selector selects elements based on the element name. eg. $("p")

  • The jQuery #id selector uses the id attribute of an HTML tag to find the specific element. eg. $("#test")

  • The jQuery .class selector finds elements with a specific class. eg. $(".test")

Events

Mouse EventsKeyboard EventsForm EventsDocument/Window Events

click

keypress

submit

load

dblclick

keydown

change

resize

mouseenter

keyup

focus

scroll

mouseleave

blur

unload

Last updated