编写两个事件,广告的显示与关闭,设定动画后,在页面加载时设定计数器,3秒后显示广告,5秒后广告自动消失
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>广告的自动显示与隐藏</title> <style> #content{width:100%;height:500px;background:#999} </style>
<script type="text/javascript" src="../js/jquery-3.3.1.min.js"></script> <script> $(function () { setTimeout(adShow,3000) setTimeout(adHide,8000) }) function adShow() { $("#ad").show("slow") } function adHide() { $("#ad").hide("slow") } </script> </head> <body>
<div> <div id="ad" style="display: none;"> <img style="width:100%" src="../img/adv.jpg" /> </div>
<div id="content"> 正文部分 </div> </div> </body> </html>
|