案例:5秒之后自动关闭广告

① 核心思路:5秒之后,就把这个广告隐藏起来

② 用定时器setTimeout()

<body>
    <img src="images/ad.jpg" alt="" class="ad">
    <script>
        var ad = document.querySelector('.ad');
        setTimeout(function() {
            ad.style.display = 'none';
        }, 5000);  
    </script>
</body> 

 

posted @ 2020-05-24 16:53  浮华夕颜  Views(558)  Comments(0Edit  收藏  举报