前端學習(1634):前端系列實戰課程之新浪延遲廣告

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #id {}
    </style>
    <script>
        window.onload = function() {
            var oImg = document.getElementById('ad');
            var timer = null;
            clearTimeout();
            timer = setTimeout(function() {
                oImg.style.display = 'none'
            }, 2000)
            oImg.onmouseover = function() {
                clearTimeout(timer);
            }
            oImg.onmouseout = function() {
                timer = setTimeout(function() {
                    oImg.style.display = 'none'
                }, 2000)
            }

        }
    </script>
</head>

<body>
    <img id="ad" src="./img/1.png" alt="" style="width: 100px;height: 100px;">
</body>

</html>

運行結果

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章