Javascript / Jquery关闭图像循环

时间:2014-12-29 16:38:14

标签: javascript jquery

我正在尝试从数组中取出项目并将其替换为<img>标记并延迟,以便我可以看到图像发生变化。它在我的小提琴中完美运行,但在Chrome独立的html页面上根本不起作用。

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    var x = ['http://static.myce.com/images_posts/2014/12/myce-popcorn-time.png','http://static.myce.com/images_posts/2014/12/myce-popcorn-time.png','http://static.myce.com/images_posts/2014/12/myce-popcorn-time.png']
    function test1(){
}
    var l = 0; 
$(document).ready(function(){
    function test2(){
for (l; l < x.length; l++) {
   $("#img").delay(1000).animate({ opacity: '0' }, (function(l) {
       return function() { $(this).attr("src", x[l]).attr("width", 100); }
   })(l)).delay(1000).animate({ opacity: '1' });

}}
});
</script>
</head>
<body>

<img id="img" src="http://static.myce.com/images_posts/2014/12/myce-popcorn-time.png"/>
<script>
test2()
</script>
</body>
</html>

0 个答案:

没有答案