jQuery选择器

1.基本选择器

   #id

   element

    .class

     *

    selector1,selector2

  2.层级选择器

    找到表单所有的input元素

    $("form input")

    parent>child 在给定的父元素下匹配所有的子元素

    pre + next 匹配所有紧接在prev元素后的next元素

    prev - sibings 匹配prev元素之后的所有siblings元素 sibings代表一个选择器,并且它作为第一个选择器的同辈

    3.基本筛选器 

     :first

      :not(selector)

      :even 匹配所有索引值为偶数的元素,从 0 开始计数

      :odd   匹配所有索引值为奇数的元素,从 0 开始计数

       :eq(index)  匹配一个给定索引值的元素

        :gt(index) 匹配所有大于给定索引值的元素

         :last 

      4 .内容选择器 

        :contains(text) 匹配包含给定文本的元素 text 一个用以查找的字符串

         :empty 匹配所有不包含子元素或者文本的空元素

          :has(selector) 匹配含有选择器所匹配的元素的元素 selector 一个用于筛选的选择器

          :parent  匹配含有子元素或者文本的元素

       5  可见性选择器 

          :hidden

           :visibile

       6  属性选择器 

          [attribute] 匹配所有给定的元素 $("div[id]")

          [attribute=value]匹配给定的属性是某个特定值的元素

          [attribute=!value] 匹配所有不含有指定的属性,或者属性不等于特定值的元素

          [attribute=^value]   

           [attribute=$value]    

            [selector1][selector2][selector3]

         7 表单选择器

           :input

           :text

           :password

            :radio

            :checkbox

            :submit

            :image 匹配所有图像域

            :reset   匹配所有重置按钮

            :button 

            :file  匹配所有文件域

        8 表单对象属性: 

              :enable 

             :disabled

             :checked

             :selected

        

        9 子元素选择器 :

              :first-child

             :last-child

             :nth-child

             :nth-last-child

             :only-child

 

          

      

        

         

  

原文地址:https://www.cnblogs.com/Ellen-study/p/7242419.html