首页 > 微信 > 详细

querySelectorAll 在部分微信版本里面foreach出现的问题

时间:2017-03-06 19:28:28      阅读:230      评论:0      收藏:0      [点我收藏+]

正如此下面的代码,出现了hello能够正常运行,但是在部分微信里面maybe不能够正常的运行 所以为了保险起见,如果要进行多个dom select 需要先Array转一下

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
	<div class="div1">1</div>
	<div class="div2">2</div>
	<script>
		var arr = document.querySelectorAll(".div1,.div2");
		console.log(arr);
		Array.from(arr).forEach(function (index,ele) {
		   console.log(111); 
		   alert(‘hello‘)        
		});
		arr.forEach(function(index,ele){
			console.log(11);
			alert(‘maybe‘);		
		});
	</script>
</body>
</html>

  

querySelectorAll 在部分微信版本里面foreach出现的问题

原文:http://www.cnblogs.com/zerohu/p/6511398.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!