Brief summary of jQuery selector (including usage examples at a glance)

  • 2020-03-30 02:41:42
  • OfStack

This article is now a summary of all the known jquery selectors, a deep and skilled grasp of these selectors, we quickly write a variety of jquery effects greatly help! Here is a list of jquery options. Since the usage of jquery is very simple, I won't give you any more examples here.

The selector The instance select * $(" # item * ") Select the id attribute for all elements under item # id $(" # lastname ") Id = "lastname" elements .class $(" type ") All the elements of class="intro" element $(" p ") All < P> The element . Class. The class $(" intro. Demo ") All the class="intro" and class="demo" elements       : first $(" p: first ") The first < P> The element : the last $(" p: last ") The last one < P> The element : even Tr: $(" even ") All even Numbers < Tr> The element : odd Tr: $(" odd ") All odd Numbers < Tr> The element : next $(' item '). Next (' div ') Class is the next div sibling of item, which is equivalent to $('.item + div') : prev $(' item '). Prev (' div ') The class is the last div sibling of the item : nextAll $(' item '). NextAll (' div ') All div siblings after the item, class, are equivalent to $('.inside ~ div') : the parent > The child $(' div > Span ') Select the first generation of the span element under div, also known as the direct child element : the parent $('. The item: the parent ') Selects the parent element of the element class as item       : eq (index) $(" ul li: eq (3) ") The fourth element in the list (index starts at 0) : gt (no) $(" ul li: gt (3) ") Lists elements whose index is greater than 3 : lt (no) $(" ul li: lt (3) ") Lists elements whose index is less than 3 : not selector () $(" input: not (empty) ") $(" input: not. (must) ") All input elements that are not empty; All elements whose class attribute is not a must       : the header $(" : the header ") All title elements < H1 > - < H6 > : animated   All animation elements       : the contains (text) $(" div: the contains (' www.phpernote.com ') ") All div elements contain all elements of the www.phpernote.com string : the empty $(". The item: the empty ") All elements without child (element) nodes in an element with a class attribute of item : hidden $(" p: hidden ") All hidden < P> The element : from the $('. The item: from the (span) ') All elements with the class attribute item contain all elements with span (whether or not they are direct) : the visible $(" table: the visible ") All visible tables       S1, s2, s3 $(" th, td, intro ") All elements with matching selections       [attribute] $(" a [href] ") All a tag elements with an href attribute [attribute = value] $(" [href = '#'] ") All elements whose value of the href attribute is equal to "#" [attribute! = value] $(" [href! = '#'] ") The value of all href attributes is not equal to the element "#" [$= value attribute] $(" [href $= 'JPG'] ") The values of all the href attributes contain elements ending in ".jpg"       : input $(" input ") All < Input> The element : text $(" text ") All type="text" < Input> The element : password $(" : "password," ") All type="password" < Input> The element : radio $(" : the radio ") All type="radio" < Input> The element : the checkbox $(" : "checkbox) All type="checkbox" < Input> The element : submit : $(" submit ") All type="submit" < Input> The element : reset $(" reset ") All type="reset" < Input> The element : button $(" button ") All type="button" < Input> The element : image : $(" image ") All type="image" < Input> The element : the file $(" : the file ") All type="file" < Input> The element       : enabled $(" enabled ") All activated input elements : disabled $(" disabled ") All disabled input elements : selected $(" selected ") All selected input elements : checked $(" checked ") All selected input elements

Related articles: