美文网首页
前端学习笔记--document.querySelectorAl

前端学习笔记--document.querySelectorAl

作者: 沧澈 | 来源:发表于2018-09-14 09:17 被阅读0次
  • for循环方式
for(var i= 0; i< document.querySelectopAll(".a").length; i ++){
        document.querySelectopAll(".a")[i].style.color= "red";
}
  • forEach

借助call()实现

[].forEach.call(document.querySelectorAll(".aa"), function(){ 
  console.log("1")       
});
参考:

https://www.cnblogs.com/yanze/p/5988142.html

相关文章

网友评论

      本文标题:前端学习笔记--document.querySelectorAl

      本文链接:https://www.haomeiwen.com/subject/kemngftx.html