• HTMLCollection length 属性


    [

    HTMLCollection length 属性
    DOM HTMLCollection

    定义和用法

    length 属性返回 HTMLCollection 对象中元素的数量。
    该属性是只读的。
    该属性在循环 HTMLCollection 对象时很有用。

    语法

    HTMLCollection.length

    返回值

    返回一个数字,表示 HTMLCollection 对象中元素的数量。

    浏览器支持

    属性
    length Yes Yes Yes Yes Yes

    实例

    实例

    循环输出所有 class="myclass 的元素并修改它们的背景颜色:

    var x = document.getElementsByClassName("myclass");

    for (i = 0; i < x.length; i++) { x.item(i).style.backgroundColor = "red"; } [/xml]

    相关文章

    HTMLCollection: item() 方法
    HTML Element: getElementsByClassName() 方法
    HTML Element: getElementsByTagName() 方法

    DOM HTMLCollection

    ]
    转载请保留页面地址:https://www.breakyizhan.com/html/23461.html
  • 相关阅读:
    融云使用
    cocoaPods使用
    电脑硬件
    拖图UI和纯代码UI
    7.2内存管理-ARC
    7内存管理-MRC
    数据刷新
    5.1音频播放
    2.6核心动画
    Git常用操作
  • 原文地址:https://www.cnblogs.com/breakyizhan/p/13272756.html
Copyright © 2020-2023  润新知