jQuary basic selector
$("div*") gets all elements below the div
$(".red,.green").html("How") // It should be noted that two choices should be written in the same quote (used when multiple selectors are selected at the same time)
$("ance desc")//ancestor ancestor selector descendant descendant selector
$("parent > child")// only includes child selectors and not grandchild selectors
$("prev + next")// "+" represents a relationship between superior and subordinate. The next element closest to the prev element is next. The selector returns and only returns the unique element.
$("p+label").css("background-color","red"); Add a background color to the neighbors next to you
$("prev ~siblings") //Get all adjacent elements after prev (adjacent elements only contain the same parent element)
Filter selector for jQuary
:first$("li:first") gets the first element in a set of identical tags that is an element not a collection
:last Last element
:eq(index) Find elements by index
$("li:eq(2)") Index gets the third element in the li tag from zero
:contains(text) Find elements by content
$("li:contains('Zhang San')") Get all the li elements that contain Zhang San, why does Zhang San have to add single quotes? Because it is a string, not a variable, an error will be reported without single or double quotes.
:has(slector) Get by element
$("li:has('p')") Gets all <li> elements containing <p> elements
:hidden Gets all invisible elements, including elements with the type attribute value hidden. $("li:hidden") Get all the following displays: none elements or hidden elements
:visible obtains all visible elements. As long as the element's display attribute value is not set to "none", it can be obtained through this selector.
$("p:visible") gets the visible <p> element
[attribute=value] Get the element whose attribute name is equal to the attribute value
$("li[title='little superman']") Adding li means determining the range If you do not add li, all selected
[attribute!=value] Get an element whose attribute name is not equal to the attribute value
[attribute*=value] Gets all elements in the 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 in each parent element. It is a collection and is often used to select data of multiple collections.
$("li:first-child") gets the first <li> element among all <ul> parent elements
:last-child Get the last child element of the parent element often uses multiple collection data selection processing
Form Selector
:input Get all elements of the form to return all form elements, including not only all form elements marked by <input>, but also <textarea>, <select> and
<button> tagged form elements, the form elements it selects are the widest
:text Getting all single lines of text input box in the form does not work for textarea
:password Get all passwords in the form input text box elements
:radio Gets all radio button elements in the form.
:checkbox Gets the checkbox element in the form. ()
:submit Gets the submit button element in the form. (Generally, there is only one button with type attribute "submit" in a form) If the button is not defined, the default is
Submit button
:image Gets the element under the class "The type attribute of the input element is image, this element is an image domain"
:image selector can only obtain <input> image fields, but cannot obtain image elements in <img> format
The :button selector can obtain and can only obtain two common button elements: <input> and <button> with the "type" attribute value of "button".
:checked Gets all elements in the selected state.
:selected Only obtains all selected <option> option elements in the <select> drop-down list box.
The above comprehensive summary of jQuary selector is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.