jQuery完成首页定时弹出图片

timingAd.html

<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
	
	<script type="text/javascript">
		$(function() {
			//书写显示广告图片的定时操作
			time = setInterval("showAd()",3000);
		});
		
		//书写显示广告图片的方法
		function showAd() {
			//获取广告图片,并让其显示
			//$("#img2").show(1000);
			$("#img2").fadeIn(6000);
			//清除显示图片的定时操作
			clearInterval(time);
			//设置隐藏图片的定时操作
			time = setInterval("hiddenAd()",3000);
		}
		
		function hiddenAd() {
			//获取广告图片,并让其隐藏
			//$("#img2").hide(3000);
			$("#img2").fadeOut(6000);
			//清除隐藏图片的定时操作
			clearInterval(time);
		}
	</script>
	
  </head>
发布了120 篇原创文章 · 获赞 9 · 访问量 4302

猜你喜欢

转载自blog.csdn.net/HuashirenYty/article/details/102755787