前端记录(自用)

Jquery使用

  1. $(‘img:not(#andus-head-img)’):所有img元素,但排除ID为#andus-head-img的元素
  2. $(“.intro.demo”):选择同时包含class=”intro”和class=”demo”的元素
  3. $(“.a, .b”):同时选择多个类型元素。(选择包含a或者包含b的元素)
  4. $(‘父标签’).on(‘click’, ‘子标签’, function(){}):监听动态添加的标签


  5. $(this):当前 HTML 元素
  6. $(“p”):所有 <p> 元素
  7. $(“p.intro”):所有 class=”intro” 的<p> 元素
  8. $(“.intro”):所有 class=”intro” 的元素
  9. $(“#intro”) id=”intro” 的元素
  10. $(“[href$=’.jpg’]”):所有带有以 “.jpg” 结尾的属性值的 href 属性
  11. $(“div#intro .head”) id=”intro” 的 <div> 元素中的所有 class=”head” 的元素
  12. $(“.good”).filter(“.list”).filter(“.Card”):依次过滤
    参考:Jquery选择器

Css

  1. 选择奇偶
    1
    2
    3
    4
    tr:nth-child(2n)
    tr:nth-child(2n+1)
    tr:nth-child(even)
    tr:nth-child(odd)
评论