zoukankan      html  css  js  c++  java
  • JS、JQ获取容器内标签的个数

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>获取容器内标签的个数</title>
    </head>
    <body>
    <div class="content" id="content">
        <div class="item"><span></span><span></span></div>
        <div class="item"><span></span><span></span></div>
        <div class="item"><span></span><span></span></div>
        <div class="item"><span></span><span></span></div>
        <div class="item"><span></span><span></span></div>
    </div>
        <script src="http://www.jq22.com/jquery/jquery-2.1.1.js"></script>
        <script type="text/javascript">
          window.onload = function(){
              var div_l = $(".content").children(".item").length;//JQ获取标签个数方法
            console.log("jq方法:",div_l);
    
            var div_m = document.getElementById("content");
            var div_n = div_m.getElementsByClassName("item").length;//js获取标签个数方法
            console.log("js方法:",div_n);
          }
        </script>
    </body>
    </html>
  • 相关阅读:
    装饰器函数
    二分查找
    jmter 二次开发 IDEA 项目5.1
    python 测试框架nose
    pycharm 参数、快捷键、调试模式
    IDea 工具debug模式详细使用说明
    MySQL zip安装
    adb 设备命令
    兰亭集序 王羲之
    adb 命令实用
  • 原文地址:https://www.cnblogs.com/liangdecha/p/9675202.html
Copyright © 2011-2022 走看看