zoukankan      html  css  js  c++  java
  • JavaScrip学习笔记_JS中的foreach

    var hobbies = document.getElementsByName("hobby");
    

    用getElementsByName和getElementsByTagName获得的数组如果用foreach进行遍历并输出结果是:

    [object HTMLInputElement]
    [object HTMLInputElement]
    [object HTMLInputElement]
    [object HTMLInputElement]
    [object HTMLInputElement]
    [object HTMLInputElement]
    [object HTMLInputElement]
    function item() { [native code] }
    function keys() { [native code] }
    function values() { [native code] }
    function entries() { [native code] }
    function forEach() { [native code] }
    7

     所以foreach获得value时会得到undefined值

  • 相关阅读:
    npm改为淘宝镜像
    html中table中td内容换行
    git 切换文件夹路径
    git经常使用的命令
    day16
    day15
    day13
    day14
    day12
    day11
  • 原文地址:https://www.cnblogs.com/annofyf/p/9436222.html
Copyright © 2011-2022 走看看