7秒后的Javascript幻灯片图像 [英] Javascript after 7 seconds slide image
本文介绍了7秒后的Javascript幻灯片图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
http://jsfiddle.net/UWLsB/189/
我试图让图像在7秒后向左滑动,它怎么不起作用?
Html:
< div id =container>
< div id =pack>
< img id =packsrc =http://imgur.com/uGMzOGM.png>
< / div>
Javascript:
function FetchData(){
$(#pack)。css('margin-left',0);
$(#pack)。css('margin-right',0);
$(#pack)。animate({
left:'-1000px'
},'slow');
});
}
setTimeout(FetchData,7000);
CSS:
#pack {
margin:5px auto;
位置:固定;
}
#container {
overflow:hidden;
解决方案
。 });
行应完全删除: $ b
http://jsfiddle.net/UWLsB/190/
我想你的意思是使用}
和)
放在同一行上,或者从一些教程中获得它:
setTimeout(function(){
// .animate call stuff here
},7000);
顺便说一下,您可以纯粹使用CSS来使用动画:
http://jsfiddle.net/UWLsB/192/
http://jsfiddle.net/UWLsB/189/
I am trying to make the image slide to the left after 7 seconds, how come it's not working?
Html:
<div id="container">
<div id="pack">
<img id="pack" src="http://imgur.com/uGMzOGM.png">
</div>
Javascript:
function FetchData() {
$("#pack").css('margin-left', 0);
$("#pack").css('margin-right', 0);
$("#pack").animate({
left: '-1000px'
}, 'slow');
});
}
setTimeout(FetchData, 7000);
CSS:
#pack {
margin: 5px auto;
position:fixed;
}
#container {
overflow:hidden;
}
解决方案
You just have a syntax error. The });
line should be removed entirely:
http://jsfiddle.net/UWLsB/190/
I think you meant to use syntax that would have }
and )
on the same line or got it from some tutorial like:
setTimeout(function () {
// .animate call stuff here
}, 7000);
By the way, you could do this purely with CSS using animations:
http://jsfiddle.net/UWLsB/192/
这篇关于7秒后的Javascript幻灯片图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文