js実装カウントダウンとjquery実装カウントダウン
2695 ワード
jquery実装カウントダウンコード:
js実装カウントダウンコード:
<script src="jquery-1.8.2.min.js">script>
<script type="text/javascript">
var i=5;
$(function(){
setTimeout(function(){
window.location.href='';
},5000);
freshen();
});
//
function freshen(){
$("#time").empty().append(i);
i=i-1;
setTimeout(function(){
freshen();
},1000);
}
script>
js実装カウントダウンコード:
(function () {
var wait = document.getElementById('time'),
href = document.getElementById('linkName').href;
var interval = setInterval(function () {
var time = --wait.innerHTML;
if (time <= 0) {
location.href = href;
clearInterval(interval);
}
;
}, 1000);
})();