js實現倒計時效果


<html>


<head>
<meta charset="UTF-8">
<title></title>
<style>
.time {
width: 200px;
height: 100px;
background-color: #CCCCCC;
border-radius: 50px;
text-align: center;
line-height: 100px;
}
</style>
</head>


<body>
<div class="time">
<span id="mytime">提示,<span id="bbb">3</span>秒後頁面跳轉到百度</span>
<a href="http://www.baidu.com">手動點擊跳轉至百度</a>
</div>
</body>
<script type="text/javascript">
var obj = document.getElementById("bbb");
var sobj = obj.innerHTML;
ting = setInterval(function() {
obj.innerHTML = --sobj;
if(sobj <= 0) {
clearInterval(ting);
window.location = 'http://www.baidu.com';
}
}, 1000);
</script>


</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章