
本文教程操作环境:windows7系统、jquery3.2.1版本,DELL G3电脑。
方法一:使用es6中数组rest方法遍历dom
使用语法
vardoms=document.querySelectorAll('div')
具体使用
vararr=[...doms]
arr.forEach((val)=>{
console.log(val.innerHTML)
})
方法二:使用使用firstElementChild,nextElementSibling遍历dom
varlist=document.getElementById('list');
varchild=list.firstElementChild;
while(child){
console.log(child);
child=child.nextElementSibling;
}原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END


















































暂无评论内容