zoukankan      html  css  js  c++  java
  • jQuery里的增强for循环遍历和$.each()遍历

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-3.2.1.min.js"></script>
    <script>
    var a=[11,22,33];
          //index,为数组当前遍历的数组的下标,elements为当前遍历到的数组元素
    $.each(a,function (index,elements) {
    console.log(elements);
    })
    //输出的a 为数组的下标
    for(var aa in a){
    console.log(a[aa]);
    }
    //obj对象
    var obj={"name":"zhangsan","age":29}
         //key为遍历到当前对象的key,value为当前key对应的值
    $.each(obj,function (key,value) {
    console.log(key+":"+value);

    })
    //输出的index 值为该对象的key值
    for(var index in obj){
    console.log(key+":"+obj[index]);
    }

    </script>
    </head>
    <body>

    </body>
    </html>
  • 相关阅读:
    css3 object-fit详解
    Timing path
    IUS
    FIFO深度
    UVM中的class--2
    UVM中的class
    Binding
    Concurrent Assertion
    Immediate assertion
    sdf
  • 原文地址:https://www.cnblogs.com/kukai/p/11019626.html
Copyright © 2011-2022 走看看