标签:元素 ble ++ 表示 地址 view classname ack tps
[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
标签:元素 ble ++ 表示 地址 view classname ack tps
原文地址:https://www.cnblogs.com/breakyizhan/p/13272756.html