Html开发中document.getElementByTagName无法找到所有DOM元素的问题解决方法

1 let eleList = document.querySelectorAll('li')
2 for (let i = 0; i < eleList.length; i++) {
3   // 遍历操作
4 }

只要使用querySelectorAll方法即可获取所有找到的DOM元素

posted @ 2018-08-14 18:08  AirNess  阅读(353)  评论(0编辑  收藏  举报