zoukankan      html  css  js  c++  java
  • 【jQuery】选择器

    jQ提供了很多选择器:(注:$("p").action() action为后续动作)

    • 元素选择器
    $("p").action() ; //选取所有p标签
    • id选择器
    $("#test").action(); //获取id为test的元素
    • class选择器
    $(".test").action();//获取class为test的所有元素
    • 更多
    $("*")                 //选取所有元素    
    $(this)                //选取当前 HTML 元素    
    $("p.intro")            //选取 class 为 intro 的 <p> 元素    
    $("p:first")              //选取第一个 <p> 元素    
    $("ul li:first")            //选取第一个 <ul> 元素的第一个 <li> 元素    
    $("ul li:first-child")        //选取每个 <ul> 元素的第一个 <li> 元素    
    $("[href]")              //选取带有 href 属性的元素    
    $("a[target='_blank']")      //选取所有 target 属性值等于 "_blank" 的 <a> 元素    
    $("a[target!='_blank']")      //选取所有 target 属性值不等于 "_blank" 的 <a> 元素    
    $(":button")               //选取所有 type="button" 的 <input> 元素 和 <button> 元素    
    $("tr:even")               //选取偶数位置的 <tr> 元素    
    $("tr:odd")               //选取奇数位置的 <tr> 元素
  • 相关阅读:
    venv(virtual environment)的使用
    Pytest 失败重运行机制
    Python 中方法和函数的区别
    手机移动端WEB资源整合
    Sass学习日志
    1、vue基础使用复习
    vscode配置笔记
    vue兼容IE浏览器、对低版本IE下的友好提示
    关闭eslint校验
    vue实现吸顶的效果
  • 原文地址:https://www.cnblogs.com/anny0404/p/5692003.html
Copyright © 2011-2022 走看看