内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

js實(shí)現(xiàn)倒計(jì)時(shí)器自定義時(shí)間和暫停

js倒計(jì)時(shí)器可自定義時(shí)間和暫停,效果如下,點(diǎn)擊start 開(kāi)始計(jì)時(shí),end結(jié)束計(jì)時(shí)

博樂(lè)網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,博樂(lè)網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為博樂(lè)千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢(qián),請(qǐng)找那個(gè)售后服務(wù)好的博樂(lè)做網(wǎng)站的公司定做!

js實(shí)現(xiàn)倒計(jì)時(shí)器自定義時(shí)間和暫停

分別復(fù)制 H5 css js 代碼即可實(shí)現(xiàn),具體的算法在js控制函數(shù)中(都寫(xiě)了注釋?zhuān)?/p>

css

 html,body{
width:100%;height:100%;
}
.content{
height:100%;width:100%; 
}
.row-center{
display:flex;flex-direction:row;justify-content:center;
align-items:center;
}
.tc-input-style{
outline:none;border:none;width:20%;height:80%;border-radius:10px;
}
.tc-span-style{
width:30%;height:100%;font-weight:bold;
}
.tc-font-style{
font-size:15px;font-weight:bold;
}
.tc-div-style1{
height:33%;width:100%
}
.tc-div-style0{
height:30%;width:100%
}
.tc-div-style2{
height:10%;width:100%; 
}
.tc-div-style3{
height:100%;width:30%
}
.column-center{
display:flex;flex-direction:column;justify-content:center;
align-items:center;
}
.column-start-center{
display:flex;flex-direction:column;justify-content:flex-start;
align-items:center;
}
#timecount{
height:50%;width:20%;
}
.button-style-0{
border-radius:10px;
}
.row-space-around{
display:flex;flex-direction:row;justify-content:space-around;
align-items:center;
}

h6

<body>
<div class="content row-center"> 

  <div id="timecount" class="column-center tc-font-style" >
  <div class="column-start-center tc-div-style0" >
  <div class="row-center tc-div-style1" ><span class="tc-span-style row-center">小時(shí):</span><input class=tc-input-style id="hour_count" value="0"> </div>
  <div class="row-center tc-div-style1" ><span class="tc-span-style row-center">分鐘:</span><input class=tc-input-style id="minute_count" value="0"> </div>
  <div class="row-center tc-div-style1" ><span class="tc-span-style row-center">秒:</span><input class=tc-input-style id="second_count" value="0"> </div>
  </div>

  <div class="row-center tc-div-style2">
  <div class="row-center tc-div-style3" id="hour_show" ></div>
  <div class="row-center tc-div-style3" id="minute_show"></div>
  <div class="row-center tc-div-style3" id="second_show"></div>
  </div>

  <div class="row-space-around tc-div-style2">
  <button class="button-style-0" onclick="timecounts()">start</button>
  <button class="button-style-0" onclick="timestop()">stop</button>
  </div>

  </div>


</div>
</body>

記得引入jq

 <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>

JS

<script type="text/javascript">
var timecount;//定義一個(gè)全局變量
function timer(intDiff){
 //定義一個(gè)循環(huán)函數(shù)每一秒定時(shí)執(zhí)行
 timecount=setInterval(function(){
 var hour=0,
 minute=0,
 second=0;//初始化時(shí)間默認(rèn)值 
 //算法控制
 if(intDiff > 0){
 hour = Math.floor(intDiff / (60 * 60)) ;
 minute = Math.floor(intDiff / 60) - (hour * 60);
 second = Math.floor(intDiff) - (hour * 60 * 60) - (minute * 60);
 }
 if (minute <= 9) minute = '0' + minute;
 if (second <= 9) second = '0' + second;
 //打印到dom
 $('#hour_show').html('<s id="h"></s>'+hour+'時(shí)');
 $('#minute_show').html('<s></s>'+minute+'分');
 $('#second_show').html('<s></s>'+second+'秒');
 intDiff--;
 }, 1000);
 console.log(intDiff); 
}

function timecounts(){
 console.log($("#hour_count").val())
 count=parseInt($("#hour_count").val()*3600)+parseInt($("#minute_count").val()*60)+parseInt($("#second_count").val())
 timer(count);//調(diào)用計(jì)時(shí)器函數(shù)
 console.log(count);
}
function timestop(){
 var hour= $("#hour_show").text();
 var minute= $("#minute_show").text();
 var second= $("#second_show").text();
 var time=parseInt($("#hour_show").text())*3600+parseInt($("#minute_show").text())*60+parseInt($("#second_show").text())
 console.log(time);
 timecount=window.clearInterval(timecount);//停止計(jì)時(shí)器
}
</script>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

網(wǎng)站名稱(chēng):js實(shí)現(xiàn)倒計(jì)時(shí)器自定義時(shí)間和暫停
文章來(lái)源:http://www.rwnh.cn/article24/jsdeje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃網(wǎng)站收錄、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站設(shè)計(jì)公司、企業(yè)建站、網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司
双辽市| 会理县| 亚东县| 盐源县| 资阳市| 巴南区| 从江县| 青浦区| 逊克县| 纳雍县| 龙胜| 调兵山市| 慈溪市| 区。| 绥中县| 十堰市| 正定县| 九江县| 原阳县| 巴林左旗| 禹城市| 南投市| 海宁市| 漯河市| 浏阳市| 子洲县| 巍山| 苏尼特左旗| 花垣县| 彭泽县| 普兰县| 炎陵县| 习水县| 江孜县| 广德县| 松潘县| 永和县| 宾阳县| 温宿县| 新乡县| 九寨沟县|