The jquery Selector is a very important part of the jquery library.
The jquery Selector is used to select an HTML element whose base statement is the same as the CSS selector (Selector), and all jquery Selector begin with $ ().
Select HTML tag
The way to select an HTML element is to use the tag name of the element directly, such as selecting all <p> elements
$ ("P")
The following example hides all <p> elements when the user clicks a button
$ (document). Ready (function () {
$ ("button"). Click (function () {
$ ("P"). Hide ();
});
#id selection
The JQuery #id selector is used to select the element that defines the id attribute, and the ID of the element on the page should be guaranteed to be unique, and you can use the ID to select a single unique element.
For example, when the button is clicked, only the element with the ID test is hidden.
<! DOCTYPE html>
. class Selector
The jQuery. Class selector selects all elements that define the class attribute as a value, such as the following example to hide elements with the class name test:
<! DOCTYPE html>