jQuery之第2章 jQuery选择器

jQuery选择器(阶梯结构):

  1、基本选择器:

      (1)#id

      (2).class

      (3)element

      (4)*

      (5)selector1,selector2....

  2、层次选择器:

      (1)$("ancestor  descendant") 后代元素

      (2)$("parent > child") 子元素

      (3)$("prev + next") 同辈元素 等价于$().next();

      (4)$("prev ~ siblings") 同辈元素 等价于 $().nextAll();

  3、过滤选择器:

    基本过滤选择器:

      (1):first

      (2):last

      (3):not(selector)

      (4):even

      (5):odd

      (6):eq(index)

      (7):gt(index)

      (8):lt(index)

      (9):header

      (10):animated

      (11):focus

    内容过滤选择器:

      (1):contains(test)

      (2):empty

      (3):has(selector)

      (4):parent

    可见性过滤选择器:

      (1):hidden

      (2):visible

    属性过滤选择器:

      (1)[attribute]

      (2)[attribute=value]

      (3)[attribute!=value]

      (4)[attribute^=value]

      (5)[attribute$=value]

      (6)[attribute*=value]

      (7)[attribute|=value]

      (8)[attribute~=value]

      (9)[attribute1][attribute2][attributeN]

    子元素过滤选择器:

      (1):nth-child(index/even/odd/equation)

      (2):first-child

      (3):last-child

      (4):only-child

    表单对象属性过滤选择器

      (1):enabled

      (2):disabled

      (3):checked 单选框、复选框

      (4):selected 下拉框

  4、表单选择器:

      (1):input 选取所有的<input>、<textarea>、<select>和<button>元素

      (2):text 选取所有的单行文本框

      (3):password

      (4):radio

      (5):checkbox

      (6):submit

      (7):image

      (8):reset

      (9):button 选取所有的按钮

      (10):file

      (11):hidden

注意:

  1、选择器中含有“·”、“#”、“(”、“]”等特殊字符需要转义。

  2、属性选择器中的@符号问题。

  3、选择器中含有空格的注意事项。

原文地址:https://www.cnblogs.com/sunny-blog/p/4023655.html