标签:values pre lis 怎样 body code type node 键值对
1. 单独遍历键: NodeList.prototype.keys();
2. 单独遍历值: NodeList.prototype.values();
3. 遍历键值对: NodeList.prototype.entries();
var children = document.body.childNodes; for (var key of children.keys()) { console.log(key); } // 0 // 1 // 2 // ... for (var value of children.values()) { console.log(value); } // #text // <script> // ... for (var entry of children.entries()) { console.log(entry); } // Array [ 0, #text ] // Array [ 1, <script> ] // ...
标签:values pre lis 怎样 body code type node 键值对
原文地址:https://www.cnblogs.com/aisowe/p/11512422.html