5秒之后关闭广告
- setTimeout(func,inener)定时函数,隔x秒后执行一次动作
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>5秒后关闭广告</title> <style type="text/css"> img{ width: 100px; height: 400px; position: absolute; } ul{ list-style: none; } ul li{ font-size: 25px; } #left{ left: 0px; } #right{ right: 0px; } </style> </head> <body> <img id="left" src="img/left.jpg"> <img id="right" src="img/right.jpg"> <ul> <li>点</li> <li>点</li> <li>点</li> </ul> </body> <script type="text/javascript"> window.onload=function (ev) { var left=document.getElementById('left'); var right=document.getElementById('right'); setTimeout(function () { left.style.display="none"; right.style.display="none"; },5000) } </script> </html>