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>
View Code

 

posted @ 2018-06-17 10:30  丫丫625202  阅读(204)  评论(0编辑  收藏  举报