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.
All selectors in jQuery start with the dollar sign and parentheses: $().
There are mainly 3 types of selector
- Element Selector
- Id Selector
- Class Selector
- Element Selector:
The jQuery element selector selects elements based on the element name.
Ex:
$(“p”);
- Id Selector:
The jQuery #id selector uses the id attribute of an HTML tag to find the specific element.
Ex:
$(“#test”)
- Class Selector:
The jQuery .class selector finds elements with a specific class.
Ex:$(“.test”)