點擊按鈕后彈出提示信息,幾秒之后跳轉到某頁面


js代碼
    //clearTimeout的作用是清除setTimeout的方法.或者說注銷setTimeout方法,讓setTimeout方法停止或無法運行.
    // 使用clearTimeout時必須指定一個參數.該參數是setTimeout返回的ID值.也就是說當你使用setTimeout時.必須要為setTimeout指定一個返回的id值.隨意指定一個變量

    // set_id=setTimeout(fun,1000);
    // function fun(){
    $(document).on("click", ".clickme", function (event) {
        $(".read-later-alert").show();
        set_id = setTimeout(function () {
            $(".read-later-alert").hide()
            window.location.href='../addTower.html'
        }, 3000);
       
        //  $(".read-later-alert").hover(function(){
        //      clearTimeout(set_id);
        //  },function(){
        //      $(this).hide();
        //  })
    });
    
    // }
View Code
html代碼
<button class="clickme">點我啊</button>

    <div class="read-later-alert" style="display:none">31465465</div>
View Code
css代碼
   .read-later-alert {
            position: absolute;
            top: 50%;
            left: 40%;
            height: 40px;
            background: rgba(48, 48, 48, 0.8);
            padding: 10px;
            -moz-border-radius: 7px;
            -webkit-border-radius: 7px;
            color: #fff;
            position: fixed;
            display: none;
            text-align: center;
            z-index: 9999;
        }
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM