Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript使用FOR OF数组循环时出错?_Javascript_Jquery_Html_Internet Explorer - Fatal编程技术网

使用javascript使用FOR OF数组循环时出错?

使用javascript使用FOR OF数组循环时出错?,javascript,jquery,html,internet-explorer,Javascript,Jquery,Html,Internet Explorer,这里,为什么我的代码在IE中不起作用。 我的代码适用于所有浏览器。没有问题。 但当我在IE上运行我的项目时,它会发现错误 还有我的jquery类和insertadjacentHTMl不工作 我在这段代码中发现的主要问题 $(“[type=slideshow]section”).addClass('hide'); for(让数组的元素从($(“[type=slideshow]”)开始){ $(ele).children(“section:first”).removeClass(“hide”).a

这里,为什么我的代码在IE中不起作用。 我的代码适用于所有浏览器。没有问题。 但当我在IE上运行我的项目时,它会发现错误

还有我的jquery类和insertadjacentHTMl不工作

我在这段代码中发现的主要问题

$(“[type=slideshow]section”).addClass('hide');
for(让数组的元素从($(“[type=slideshow]”)开始){
$(ele).children(“section:first”).removeClass(“hide”).addClass(“active”);

}
在IE上不受支持。您可以用jquery的
每个
替换循环的

$("[type=slideshow] section").addClass('hide');
$("[type=slideshow]").each( function(i,ele){ //i is the index and ele is the element in iteration
   $(ele).children("section:first").removeClass("hide").addClass('active');
});
另外,无需将jquery与javascript的
查询选择器
混合使用,并使用for循环对结果进行循环

使用基于#的选择器时,请按此行中的方式滑动

var divSlide = document.querySelectorAll('#slide');
它只会给出一个结果,简单地使用

timeline = $( "#slide" )[0];

不需要外部for循环和if条件。

IE上的错误到底是什么?:应为“;”这是在控制台中显示的。Log这是因为IE中完全不支持“
for..of
”:为什么不使用jquery的
each
?@gurvinder372来迭代
$(“[type=slideshow]”)呢?因为我有4个div,除了type=timeline和slidehsow之外,其他都是一样的。所以我使用每个$(“[类型=幻灯片])。给我一些建议gurvinder pajji。当然,很乐意帮助!