核心代码:
timeOut();
/* 实现倒计时 */
function timeOut() {
setTimeout(function () {
$('.sec').text(--wait);
timeOut();
}, 1000);
if (wait == 0) {
window.location.reload();
}
}
前台代码:
<div class="modal-footer">
<button type="button" class="btn btn-default btn_close" onclick="clo()">
<i class="icon-eye-close"></i>
<b>关闭</b>
</button>
<button type="button" class="btn btn-primary" onclick="addTypeN()" id="btnadd">
<i class="icon-ok white"></i>
<b class="settime_add">添加</b>
<span class="setspan"><strong class="tishi"></strong><i class="sec">2</i> 秒跳转</span>
<span class="czspan"></span>
</button>
</div>
效果图: