案例: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> 
原文地址:https://www.cnblogs.com/zcy9838/p/12951526.html