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

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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值