中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

jQuery計時器

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標題文檔</title>
<script type="text/javascript" src="jquery.min.js"></script>
<style>
.btnl,btnr{ width:60px;height:25px;}
</style>
</head>
 
<body>
 
<input type="text" class="showTime">
<button class="btnl">開始</button>
<button class="btnr">結(jié)束</button>
<script type="text/javascript">
 var timeIndex = 0;
 $(".btnl").click(function(){    //點擊btnl觸發(fā)setTime()函數(shù)
 setTime();
 times = setInterval(setTime, 1000);    //每隔1秒執(zhí)行函數(shù)
 });
 $(".btnr").click(function(){
 clearInterval(times);    //清除對函數(shù)的調(diào)用
 });
 function setTime(){
 var hour = parseInt(timeIndex / 3600);    // 計算時 
 var minutes = parseInt((timeIndex % 3600) / 60);    // 計算分 
 var seconds = parseInt(timeIndex % 60);    // 計算秒  
 hour = hour < 10 ? "0" + hour : hour;
 minutes = minutes < 10 ? "0" + minutes : minutes;
 seconds = seconds < 10 ? "0" + seconds : seconds;
 $(".showTime").val(hour + ":" + minutes + ":" + seconds);
 timeIndex++;
 }
</script>

捕獲

parseInt() 函數(shù)可解析一個字符串,并返回一個整數(shù)。

setInterval() 方法會不停地調(diào)用函數(shù),直到 clearInterval() 被調(diào)用或窗口被關閉。

由 setInterval() 返回的 ID 值可用作 clearInterval() 方法的參數(shù)。

來自: jQuery計時器

標簽:

版權申明:本站文章部分自網(wǎng)絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:后綴數(shù)組之倍增算法

下一篇:PHP 上傳文件大小限制