您的位置:首页 > Web前端 > JQuery

第二章-jQuery选择器

2016-05-29 10:44 525 查看
一、jquery选择器的优势:

  ①简介的写法

  ②支持css1-css3选择器

  ③完善的处理机制

二、jQuery选择器分类:

  ①基本选择器

    ①#id

    ②.class

    ③element

    ④*

    ⑤selector1,selector2,......

  ②层次选择器

    ①后代选择器

    ②$("parent>child") 儿子选择器

    ③$("prev+next")选择下一个同辈元素 等价于next()

    ④$("prev~siblings")选择后面的所有同辈元素 等价于nextAll()

    ps:siblings()匹配所有同辈元素,与前后位置无关

  ③过滤选择器

    ①基本过滤

      ①:first

      ②:last

      ③:not(selector)

      ④:even

      ⑤:odd

      ⑥:eq(index)

      ⑦:gt(index)

      ⑧:lt(index)

      ⑨:header

      ⑩:animated

      ⑪:focus

    ②内容过滤

      ①:contains(text)

      ②:empty

      ③:has(selector)

      ④:parent

    ③可见性过滤

      ①:hidden 注意:包含样式display:none/visibility:hidden的元素,或者文本隐藏域<input type="hidden"/>之类的元素

      ②:visible  

    ④属性过滤

      ①[attribute]

      ②[attribute=value]

      ③[attribute!=value]

      ④[attribute^=value]

      ⑤[attribute$=value]

      ⑥[attribute*=value]

      ⑦[attribute|=value]

      ⑧[attribute~=value]

      ⑨[attribute1][attribute2][attributeN]

    ⑤子元素过滤

      ①:nth-child(index/even/odd/equation) 例子::nth-child(3n) :nth-child(3n+1)

      ②:first-child

      ③:last-child

      ④:only-child

    ⑥表单对象属性过滤

      ①:enabled

      ②:disabled

      ③:checked (针对单选框 复选框)

      ④:selected (针对下拉列表)

  ④表单选择器

    ①:input

    ②:text

    ③:password

    ④:radio

    ⑤:checkbox

    ⑥:submit

    ⑦:image

    ⑧:reset

    ⑨:button

    ⑩:file

    ⑪:hidden
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: