zoukankan      html  css  js  c++  java
  • jQuery常用子元素过滤选择器

    !DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title>常用子元素过滤选择器</title>
        <script src="scripts/jquery-3.1.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            //:first-child 当前元素是父亲的第一个儿子
            //这个排行不包括文本
            $(function(){
                /*alert($("li:first-child").length);
                alert($("li:first-child").text());
                //first-of-type 是当前元素父亲的当前类型儿子中的一个
                alert($("li:first-of-type").length);*/
                //:only-child 是父亲唯一的儿子
                //alert($("span:only-child").length);//1
                //only-of-type 是父亲当前类型的唯一的儿子
                //alert($("span:only-of-type").length)
                //nth-child(index/odd/even)
                //是父亲的奇数个孩子   下标从1开始
                alert($("ul li:nth-child(odd)").length);
            });
    
        </script>
    </head>
    <body>
    <div>
        <div id="div1">
            <h3 class="one">手机品牌</h3>
            <ul class="one">
                <span>test11</span>
                <li class="one">苹果</li>
                <li class="one">华为</li>
                <li class="one">vivo</li>
            </ul>
            <p>
                <span>test22</span>
            </p>
            <h3>电脑品牌</h3>
            <ul class="one">
                <span>test</span>
                <li>联想</li>
                <li>苹果</li>
                <li hidden="true">戴尔</li>
                <li hidden="true">东芝</li>
                <span>test</span>
            </ul>
        </div>
        <div>
            <h3>销量排行</h3>
            <ol>
                <li>vivo</li>
                <li>苹果</li>
                <li>华为</li>
            </ol>
        </div>
        hahafinish
    </div>
    </body>
    </html>
    

      

  • 相关阅读:
    完全分布式安装HBase
    HDFS常用的文件API操作
    启动HBase后遇到的一个问题
    HBase常用的数据库API操作
    HBase数据库常用操作命令
    Hive安装
    eclipse中配置hadoop开发环境
    Hadoop小程序倒排索引
    我学习设计模式的一些所想所得
    架构之路实战项目记录(二) 忘记数据库 开始抽象
  • 原文地址:https://www.cnblogs.com/john568300/p/6420967.html
Copyright © 2011-2022 走看看