jQuery选择器的类型是什么? [英] What are the types of jquery selectors?

查看:90
本文介绍了jQuery选择器的类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此问题有疑问,但是没有很好的消息来源,请您能帮我吗?什么是选择器?

I'm having a problem with this question and didn't have any good source, can you please help me ? What are the selectors?

推荐答案

这些是jquery选择器(从jQuery 1.10和jQuery 2.0开始):

These are the jquery selectors (as of jQuery 1.10 and jQuery 2.0):

  • 所有选择器("*")
    选择所有元素.
  • :animated选择器
    选择器运行时,选择动画进行中的所有元素.
  • 属性包含前缀选择器[name|="value"]
    选择具有指定属性的元素,该元素的值等于给定字符串,或者以该字符串开头,后跟连字符(-).
  • 属性包含选择器[name*="value"]
    选择具有指定属性且其值包含给定子字符串的元素.
  • 属性包含单词选择器[name~="value"]
    选择具有指定属性的元素,该元素的值包含以空格分隔的给定单词.
  • 属性以选择器[name$="value"]
    结尾 选择具有指定属性且其值恰好以给定字符串结尾的元素.比较是区分大小写的.
  • 等于属性的选择器[name="value"]
    选择具有指定属性且其值完全等于某个特定值的元素.
  • 属性不等于选择器[name!="value"]
    选择不具有指定属性或具有指定属性但不具有特定值的元素.
  • 属性始于选择器[name^="value"]
    选择具有指定属性的元素,该元素的值恰好以给定字符串开头.
  • :button选择器
    选择所有按钮元素和按钮类型的元素.
  • :checkbox选择器
    选择所有类型的元素复选框.
  • :checked选择器 匹配所有选中或选中的元素.
  • 子选择器("parent > child")
    选择父"指定的元素的子"指定的所有直接子元素.
  • 类选择器(".class")
    选择具有给定类的所有元素.
  • :contains()选择器
    选择所有包含指定文本的元素.
  • 后代选择器("ancestor descendant")
    选择作为给定祖先的后代的所有元素.
  • :禁用的选择器
    选择所有禁用的元素.
  • 元素选择器(元素")
    选择具有给定标签名称的所有元素.
  • :空选择器
    选择所有没有子元素的元素(包括文本节点).
  • :已启用选择器
    选择所有启用的元素.
  • :eq()选择器
    选择匹配集中索引n处的元素.
  • :均匀选择器
    选择零索引的偶数元素.另请参见奇数.
  • :文件选择器
    选择文件类型的所有元素.
  • :第一个孩子选择器
    选择作为其父级的第一个子级的所有元素.
  • :第一个选择器
    选择所有具有相同元素名称的同级元素中的第一个元素.
  • :第一个选择器
    选择第一个匹配的元素.
  • :焦点选择器
    选择当前处于焦点状态的元素.
  • :gt()选择器
    选择索引大于匹配集中索引的所有元素.
  • 具有属性选择器[名称]
    选择具有指定属性且具有任何值的元素.
  • :具有()选择器
    选择包含至少一个与指定选择器匹配的元素的元素.
  • :标题选择器
    选择所有作为标头的元素,例如h1,h2,h3等.
  • :隐藏选择器
    选择所有隐藏的元素.
  • ID选择器("#id")
    选择具有给定id属性的单个元素.
  • :图像选择器
    选择类型为image的所有元素.
  • :输入选择器
    选择所有输入,文本区域,选择和按钮元素.
  • :lang()选择器
    选择指定语言的所有元素.
  • :最后一个选择器
    选择作为其父级的最后一个子级的所有元素.
  • :类型最后的选择器
    选择所有具有相同元素名称的兄弟姐妹中的最后一个元素.
  • :最后一个选择器
    选择最后一个匹配的元素.
  • :lt()选择器
    选择索引小于匹配集中索引的所有元素.
  • **多个属性选择器[name ="value"] [name2 ="value2"] 匹配与所有指定的属性过滤器匹配的元素.
  • 多个选择器("selector1,selector2,selectorN")
    选择所有指定选择器的合并结果.
  • 下一个相邻选择器(上一个+下一个")
    选择所有与"next"匹配的next元素,紧接其后的是同级"prev".
  • 下一个兄弟姐妹选择器(上一个〜兄弟姐妹")
    选择所有在"prev"元素之后的兄弟元素,它们具有相同的父元素,并与过滤兄弟姐妹"选择器匹配.
  • :not()选择器
    选择与给定选择器不匹配的所有元素.
  • :nth-​​child()选择器
    选择作为其父项的第n个子项的所有元素.
  • :nth-​​last-child()选择器
    选择从上一个元素到第一个元素的所有元素,作为其父元素的第n个子元素.
  • :nth-​​last-of-type()选择器
    从上一个元素到第一个元素,选择所有作为其父元素的第n个子元素的元素.
  • :nth-​​of-type()选择器
    选择相对于具有相同元素名称的同级元素而言,其父元素的第n个子元素的所有元素.
  • :奇数选择器
    选择零索引的奇数元素.另请参见.
  • :独生子选择器
    选择所有元素作为其父元素的唯一子元素.
  • :仅类型选择器
    选择没有相同名称的兄弟姐妹的所有元素.
  • :父级选择器
    选择具有至少一个子节点的所有元素(元素或文本).
  • :密码选择器
    选择类型为password的所有元素.
  • :无线电选择器
    选择单选类型的所有元素.
  • :重置选择器
    选择所有类型为reset的元素.
  • :根选择器
    选择作为文档根目录的元素.
  • :选择的选择器
    选择所有选定的元素.
  • :提交选择器
    选择类型为Submit的所有元素.
  • :目标选择器
    选择由文档URI的片段标识符指示的目标元素.
  • :文本选择器
    选择文本类型的所有元素.
  • :可见选择器
    选择所有可见的元素.
  • All Selector ("*")
    Selects all elements.
  • :animated Selector
    Select all elements that are in the progress of an animation at the time the selector is run.
  • Attribute Contains Prefix Selector [name|="value"]
    Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-).
  • Attribute Contains Selector [name*="value"]
    Selects elements that have the specified attribute with a value containing the a given substring.
  • Attribute Contains Word Selector [name~="value"]
    Selects elements that have the specified attribute with a value containing a given word, delimited by spaces.
  • Attribute Ends With Selector [name$="value"]
    Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.
  • Attribute Equals Selector [name="value"]
    Selects elements that have the specified attribute with a value exactly equal to a certain value.
  • Attribute Not Equal Selector [name!="value"]
    Select elements that either don’t have the specified attribute, or do have the specified attribute but not with a certain value.
  • Attribute Starts With Selector [name^="value"]
    Selects elements that have the specified attribute with a value beginning exactly with a given string.
  • :button Selector
    Selects all button elements and elements of type button.
  • :checkbox Selector
    Selects all elements of type checkbox.
  • :checked Selector Matches all elements that are checked or selected.
  • Child Selector ("parent > child")
    Selects all direct child elements specified by "child" of elements specified by "parent".
  • Class Selector (".class")
    Selects all elements with the given class.
  • :contains() Selector
    Select all elements that contain the specified text.
  • Descendant Selector ("ancestor descendant")
    Selects all elements that are descendants of a given ancestor.
  • :disabled Selector
    Selects all elements that are disabled.
  • Element Selector ("element")
    Selects all elements with the given tag name.
  • :empty Selector
    Select all elements that have no children (including text nodes).
  • :enabled Selector
    Selects all elements that are enabled.
  • :eq() Selector
    Select the element at index n within the matched set.
  • :even Selector
    Selects even elements, zero-indexed. See also odd.
  • :file Selector
    Selects all elements of type file.
  • :first-child Selector
    Selects all elements that are the first child of their parent.
  • :first-of-type Selector
    Selects all elements that are the first among siblings of the same element name.
  • :first Selector
    Selects the first matched element.
  • :focus Selector
    Selects element if it is currently focused.
  • :gt() Selector
    Select all elements at an index greater than index within the matched set.
  • Has Attribute Selector [name]
    Selects elements that have the specified attribute, with any value.
  • :has() Selector
    Selects elements which contain at least one element that matches the specified selector.
  • :header Selector
    Selects all elements that are headers, like h1, h2, h3 and so on.
  • :hidden Selector
    Selects all elements that are hidden.
  • ID Selector ("#id")
    Selects a single element with the given id attribute.
  • :image Selector
    Selects all elements of type image.
  • :input Selector
    Selects all input, textarea, select and button elements.
  • :lang() Selector
    Selects all elements of the specified language.
  • :last-child Selector
    Selects all elements that are the last child of their parent.
  • :last-of-type Selector
    Selects all elements that are the last among siblings of the same element name.
  • :last Selector
    Selects the last matched element.
  • :lt() Selector
    Select all elements at an index less than index within the matched set.
  • **Multiple Attribute Selector [name="value"][name2="value2"] Matches elements that match all of the specified attribute filters.
  • Multiple Selector ("selector1, selector2, selectorN")
    Selects the combined results of all the specified selectors.
  • Next Adjacent Selector ("prev + next")
    Selects all next elements matching "next" that are immediately preceded by a sibling "prev".
  • Next Siblings Selector ("prev ~ siblings")
    Selects all sibling elements that follow after the "prev" element, have the same parent, and match the filtering "siblings" selector.
  • :not() Selector
    Selects all elements that do not match the given selector.
  • :nth-child() Selector
    Selects all elements that are the nth-child of their parent.
  • :nth-last-child() Selector
    Selects all elements that are the nth-child of their parent, counting from the last element to the first.
  • :nth-last-of-type() Selector
    Selects all elements that are the nth-child of their parent, counting from the last element to the first.
  • :nth-of-type() Selector
    Selects all elements that are the nth child of their parent in relation to siblings with the same element name.
  • :odd Selector
    Selects odd elements, zero-indexed. See also even.
  • :only-child Selector
    Selects all elements that are the only child of their parent.
  • :only-of-type Selector
    Selects all elements that have no siblings with the same element name.
  • :parent Selector
    Select all elements that have at least one child node (either an element or text).
  • :password Selector
    Selects all elements of type password.
  • :radio Selector
    Selects all elements of type radio.
  • :reset Selector
    Selects all elements of type reset.
  • :root Selector
    Selects the element that is the root of the document.
  • :selected Selector
    Selects all elements that are selected.
  • :submit Selector
    Selects all elements of type submit.
  • :target Selector
    Selects the target element indicated by the fragment identifier of the document’s URI.
  • :text Selector
    Selects all elements of type text.
  • :visible Selector
    Selects all elements that are visible.

来源: http://api.jquery.com/category/selectors/

这篇关于jQuery选择器的类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆