首页 > 其他 > 详细

点击按钮后弹出提示信息,几秒之后跳转到某页面

时间:2019-08-10 15:34:48      阅读:244      评论:0      收藏:0      [点我收藏+]
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

 

点击按钮后弹出提示信息,几秒之后跳转到某页面

原文:https://www.cnblogs.com/heyiming/p/11331481.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!