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

# jQuery

{% embed url="https://jquery.com/" %}

{% embed url="https://www.youtube.com/watch?v=UU-GebNqdbg" %}

#### Features:

* HTML/DOM manipulation
* CSS manipulation
* HTML event methods
* Effects and animations
* AJAX
* Utilities

## Usage

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

## Syntax

```javascript
$(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

<table><thead><tr><th width="156">Mouse Events</th><th width="162">Keyboard Events</th><th width="133">Form Events</th><th>Document/Window Events</th></tr></thead><tbody><tr><td>click</td><td>keypress</td><td>submit</td><td>load</td></tr><tr><td>dblclick</td><td>keydown</td><td>change</td><td>resize</td></tr><tr><td>mouseenter</td><td>keyup</td><td>focus</td><td>scroll</td></tr><tr><td>mouseleave</td><td> </td><td>blur</td><td>unload</td></tr></tbody></table>
