A comprehensive summary of the jQuary selector
- 2021-06-29 06:19:16
- OfStack
jQuary Basic Selector
$("div*") Gets all the elements below div
$(".red,.green"). html ("How")//It is important to note that both selections are preceded by the same quotation mark (when multiple selectors need to be selected at the same time)
$("ance desc") //ancestor ancestor selector descendant descendant selector
$("parent" > child") //Contains only child selectors but not grandchild selectors
$("prev + next") //"+" denotes a superior-subordinate relationship. The next element closest to the prev element is next, and the selector returns only one element
$("p+label"). css ("background-color", "red");Add a background color to your neighbors
$("prev ~siblings") //Get all adjacent elements after prev (adjacent only contains one parent element)
jQuary Filter Selector
: first $("li:first") Obtains that the first element in the same set of labels is an element, not a collection
: Last element of last
: eq (index) Finds elements by index
The $("li:eq(2)") index retrieves the third element in the li tag from zero
: contains (text) Find Elements by Content
$("li: contains ('Zhang 3')) Gets all li elements that contain Zhang 3 Why must they be single quoted?Because it is a string, not a variable, it will fail without single or double quotation marks.
: has (slector) is obtained by element
$("li:has ('p'))) obtained the inclusion < p > All elements < li > element
: hidden takes all invisible elements, including those with an type attribute value of hidden. $("li:hidden ") Gets all display:none elements under li or elements of hidden
: visible takes all visible elements and can be obtained through this selector as long as the display attribute value of the element is not set to "none".
$("p:visible") Get Visible < p > element
[attribute=value] Gets the element whose attribute name is equal to the attribute value
$("li [title='Little Superman'])") Adding li determines the scope and chooses all if li is not added
[attribute!=value] Gets an element whose attribute name is not equal to the attribute value
[attribute*=value] Gets all elements of an attribute value that contain the specified content
$("li [title*='New']") Gets the li element containing "New" in the attribute value
: first-child Gets the first child element returned from each parent element, which is a collection, commonly used for selection processing of data from multiple collections.
$("li:first-child") Get all < ul > First of Parent Elements < li > element
: last-child Gets the last child element of a parent element's total Selection processing for data from multiple collections
Form Selector
: input takes all the elements of the form and returns all the form elements, not only all of them < input > Tagged form elements that also include < textarea > , < select > and
<
button
>
Tagged form element, which is the most widely selected form element
: text fetches all single-line text input boxes in the form and does not work for textarea
: password gets all the password entry text box elements in the form
: radio gets all the radio button elements in the form.
: checkbox gets the check box elements in the form. ()
: submit gets the submit button element in the form. (1 In a general form, only one type attribute is a button for "submit") If button is not defined, it defaults to
Submission button for submit
: image Obtains that when the type attribute of the input element is image, the element is an element under the class Image Domain
: image selector can only be obtained
<
input
>
Image domains, not available
<
img
>
Image elements of the format
: The button selector can obtain only those with an type attribute value of button
<
input
>
and
<
button
>
These two types of common button elements.
: checked gets all elements in the selected state.
: selected can only be obtained < select > All in the selected state in the drop-down list box < option > Option element.