zoukankan      html  css  js  c++  java
  • 选择器~子元素筛选

    1.jQuery( ":first-child" )

    选择所有父级元素下的第一个子元素。

    $("div span:first-child")————>div下span的第一个与first不同的是可多个

    2.jQuery( ":last-child" )

    选择所有父级元素下的最后一个子元素。

    $("div span:last-child")————>div下span的最后一个与last不同的是可多个

    3.jQuery( ":first-of-type" )

    选择所有相同的元素名称的第一个兄弟元素。

    $("span:first-of-type") ————>比如span有2组选中的就是每组的第一个

    4.jQuery( ":first-of-type" )

    选择所有相同的元素名称的最后一个兄弟元素。

    $("span:last-of-type") ————>比如span有2组选中的就是每组的最后一个

    5.jQuery( ":nth-child(index/even/odd/equation)" )

    选择的他们所有父元素的第n个子元素。

    $("ul li:nth-child(2)")

    $("ul li:nth-child(3n+1)")————》[0,1,2,3,4,5,6,7,8]

    $("ul li:nth-child(n+3)")————》[0,1,2,3,4,5,6,7,8]

    $("ul li:nth-child(even)")————》[0,1,2,3,4,5,6,7,8]

    注:nth-child()中的参数是从1开始

  • 相关阅读:
    web前端面试题
    Delphi控制摄像头
    表达式计算
    web services基础知识二
    soap和web services
    IdTCPClient和IdTCPServer主要属性
    工控控件组iocomp的iplot控件的使用
    编译开关
    delphi web services控件组
    將FastReport存入數據庫,讀出并更新
  • 原文地址:https://www.cnblogs.com/BobSky/p/3155120.html
Copyright © 2011-2022 走看看