jquery如何来回重复执行

比如说我想要一张图片 在网页刚开始的时候显示,然后过过2秒钟又隐藏,然后又显示,这样的代码怎么写?
$(document).ready(function(){
$('img').toggle(300);

})

var thisImg = $('#testimg');
thisImg.animate({'left': '0px'}, 2000, function(){
thisImg.fadeOut(500, function(){
thisImg.fadeIn(500)
})
})

亲试通过。第一个.animate({'left': '0px'}, 2000, function(),这个left:0px是无效的,只为做2000毫秒的延时,在你使用中如果使用绝对定位了,那么就换成一个无关紧要的属性即可。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-12
$(document).ready(function(){
window.setInterval(function(){
$('img').toggle(300);
},2*1000 });追问

谢谢,但是能不是用
animate的 opacity的效果来....
toggle这个是从角落里面出来显示隐藏的效果,
反复执行的效果有了,谢谢