zoukankan      html  css  js  c++  java
  • jQuery基础——选择器

    一、基础知识

      jQuery选择器返回的结果(jQuery对象)都是数组的形式。

      jQuery对象 和 Dom对象转换:

        - jQuery对象[下标(索引)]   =>  Dom对象

        - $(Dom对象)                     =>  jQuery对象

    二、基本选择器

      1、id选择器   =>  $("#id")

      2、class选择器  =>  $(".class")

      3、element选择器  =>  $("element")

      4、selector1,…,selectorN群选择器  => $("selector1,selector2...selectorN")

      5、* 选择器  =>  $("*")  匹配所有标签,多用于上下文搜索

    三、层级选择器

      1、空格(找子子孙孙)  =>  $("parent children")  例 $("div a"):div中所有a标签

      2、>(儿子)  =>  $("parent>child")  例 $("div a"):div标签下一级(儿子)中所有a标签

      3、prev + next  =>  $("prev+next")  匹配所以紧接在prev元素后面的next元素(同辈)

      4、prev ~ siblings  =>  $("prev~sibings")  匹配所有prev元素之后的同辈siblings元素

    四、基本筛选器

      1、:first  所有匹配元素中的第一个元素

      3、:last  所有匹配元素中的最后一个元素

      3、:eq(index) :匹配指定索引的元素

      4、:even:所有匹配元素偶数项

      5、:odd:所有匹配元素奇数项

      6、:gt(index):所有匹配元素中大于索引的项

      7、:lt(index):所有匹配元素中小于索引的项

    五、属性选择器

      1、$("[name]")  =>所有具有name属性的标签

      2、$("[name = 'a']")  =>所有name属性值为‘a’的标签

    六、表单选择器

      1、$(":input") =>  匹配所有 input, textarea, select 和 button 元素

      2、$(":text")  =>  匹配所有单行文本框

      3、$(":password")  =>  匹配所有密码框

      4、$(":checkbox")

      5、$(":submit")

      6、$(":radio")

      7、$(":button")

    七、表单对象属性

      1、$("input:enabled")

      2、$("input:disabled")

      3、$("input:checked")

      4、$("select option:selected")

  • 相关阅读:
    vue 中 过滤filter 和 foreach的使用
    vuex 获取数据
    动态设置样式 calc计算
    vue-echarts-v3 使用 dataZoom属性 相关笔记
    访存加速-Speed-up of Memory Access Intensive Program
    台式机新添内存条无法开机?
    ADB的版本问题
    1184. Distance Between Bus Stops
    485. Max Consecutive Ones
    448. Find All Numbers Disappeared in an Array
  • 原文地址:https://www.cnblogs.com/yz9110/p/8868999.html
Copyright © 2011-2022 走看看