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();
// })
});
// }
html代码
<button class="clickme">点我啊</button>
<div class="read-later-alert" style="display:none">31465465</div>
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;
}
来源:oschina
链接:https://my.oschina.net/u/4339899/blog/3434522