何のを為に生きて行くのか
2019年5月2日 星期四
[Back To Basic] Javascript - DOM Collections
HTMLCollection 是一個物件(object),陣列狀的一種型別。
可以用 index 取出 HTMLCollection 中的元素
e.g.
const collection = document.getElementsByTagName('p');
const text = collection[1].textContent; // 取出文字
取得 HTML Collection 數量: collection.length; // 取得長度
HTMLCollection 不是陣列,不能用陣列的方法(methods)
source code
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言