JQuery Selectors Method Description

Source: Internet
Author: User

Basic Selector
$ ("#myDiv") matches unique element with this ID value
$ ("div") matches all elements of the specified name
$ (". MyClass") matches all elements with this class style value
$ ("*") matches all elements
$ ("Div,span,p.myclass") union of all matching selectors


Cascade Selector
$ ("form input") descendant selector, select all descendant nodes of ancestor
$ ("#main > *") Sub-selector, select all child nodes of parent
$ ("label + input") Pro selector, select Prev Next Pro node
$ ("#prev ~ div") Sibling selector, select all sibling nodes of Prev


Basic Filter Selector
$ ("Tr:first") matches the first selected element
$ ("Tr:last") matches the last selected element
$ ("Input:not (: Checked) + span") filters all elements of the matching selector from the collection of original elements (there is a pro selector)
$ ("Tr:even") matches all elements of an even position in the collection (starting at 0)
$ ("tr:odd") matches all elements of an odd position in the collection (starting at 0)
$ ("Td:eq (2)") matches the element at the specified position in the collection (starting from 0)
$ ("TD:GT (4)") matches all elements after the specified position in the collection (starting from 0)
$ ("TD:GL (4)") matches all elements before the specified position in the collection (starting from 0)
$ (": Header") matches all headings
$ ("div:animated") matches all elements that are running the animation


Content Filter Selector
$ ("Div:contains (' John ')") matches all elements that contain the specified text
$ ("Td:empty") matches all empty elements (elements containing only text are not empty elements)
$ ("Div:has (P)") again matches all elements containing at least one selector from the original element collection
$ ("td:parent") matches all elements that are not empty (also counted as elements containing text)
$ ("Div:hidden") matches all hidden elements and also includes hidden fields of the form
$ ("div:visible") matches all visible elements


Attribute Filter Selector
$ ("Div[id]") matches all elements with the specified attribute
$ ("input[name= ' newsletter ')" matches all elements with the specified attribute value
$ ("input[name!= ' newsletter ')" matches all elements that do not have the specified attribute value
$ ("input[name^= ' News ']") matches all elements of the specified attribute value starting with value
$ ("input[name$= ' letter ')") matches all elements of the specified attribute value ending with value
$ ("input[name*= ' Man ']") matches all elements of the specified attribute value that contain the value character
$ ("input[id][name$= ' Man ']") matches all elements that match multiple selectors simultaneously


child element Filter Selector
$ ("UL Li:nth-child (2)"),
$ ("ul Li:nth-child (Odd)"), matching the nth child element of the parent element
$ ("ul Li:nth-child (3n + 1)")
$ ("div span:first-child") matches the 1th child element of a parent element
$ ("div span:last-child") matches the last 1 child elements of a parent element
$ ("div button:only-child") matches only 1 child elements of a parent element


Form element Selector
$ (": input") matches all form input elements, including all types of input, textarea, select, and button
$ (": Text") matches all input elements of type text
$ (":p Assword") matches all input elements of type password
$ (": Radio") matches all input elements of type radio
$ (": checkbox") matches all input elements of type checkbox
$ (": Submit") matches all input elements of type submit
$ (": Image") matches all input elements of type image
$ (": Reset") matches all input elements of type reset
$ (": Button") matches all input elements of type button
$ (": File") matches all input elements of type file
$ (": hidden") matches all input elements of type hidden or hidden fields of form


Form Element Filter Selector
$ (": Enabled") matches all actionable form elements
$ (":d isabled") matches all non-actionable form elements
$ (": Checked") matches all selected elements
$ ("Select Option:selected") matches all selected elements

JQuery Selectors Method Description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.