使用JQuery完成页面定时弹出广告,分享


使用JQuery完成页面定时弹出广告

Js相关技术

定时器:
​ setInterval & clearInterval
​ setTimeout & clearTimeout

显示: img.style.display = "block"
隐藏: img.style.display = "none"

img 对象
​ style属性: style对象

需求分析

当用户打开界面,3秒钟之后弹出广告,这个广告显示5秒钟,隐藏广告

技术分析

定时器: setTimeout
显示和隐藏: style.display = "block/none"

步骤分析:

代码实现

<!DOCTYPE html> <html> 	<head> 		<meta charset="UTF-8"> 		<title></title> 		<script type="text/javascript" src="../js/jquery-1.11.0.js" ></script> 		<!-- 			1. 导入JQ的文件 			2. 编写JQ的文档加载事件 			3.  启动定时器 setTimeout("",3000); 			4. 编写显示广告的函数 			5. 在显示广告里面再启动一个定时器 			6. 编写隐藏广告的函数 		--> 		<script> 			//显示广告 			function showAd(){ 				$("#img1").slideDown(2000); 				setTimeout("hideAd()",3000); 			} 			 			//隐藏广告 			function hideAd(){ 				$("#img1").slideUp(2000); 			} 			 			 			$(function(){ 				setTimeout("showAd()",3000); 				 			}); 		</script> 	</head> 	<body> 		<img src="../img/f001a62f-a49d-4a4d-b56f-2b6908a0002c_g.jpg" id="img1" width="100%" style="display:none"  /> 	</body> </html>  

www.dengb.comtruehttps://www.dengb.com/jQuery/1404028.htmlTechArticle使用JQuery完成页面定时弹出广告, 使用JQuery完成页面定时弹出广告 Js相关技术 定时器: ​setInterval clearInterval ​setTimeout clearTimeout 显示: i…

—-想了解更多的jQuery特效教程关注<计算机技术网(www.ctvol.com)!!>

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/jquerytutorial/110520.html

(0)
上一篇 2020年5月6日
下一篇 2020年5月6日

精彩推荐