国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JavaScript > 正文

html 和js 中實現倒計時功能

2020-03-24 19:26:25
字體:
來源:轉載
供稿:網友
倒計時主要用到的知識點:1、設置時間間隔的setInterval可以被clearInterval取消

2、毫秒轉換為時分格式

這個是效果圖

下面是js中的函數


var shijian=3600; var time=null; function start(){ time=setInterval( count() ,1000);//返回值time只是為了需要暫停的時候clearInterval(time)清除時間間隔 function count(){ if(shijian 0){ alert( time out  pause();//一般情況下這個if條件是用來提交數據用的,這里只是測試一下。 }else{ $( #time p ).html(Math.floor(shijian/60)+ : +shijian%60);//這里用到將毫秒轉換到時分格式 shijian--; console.info(time); function pause(){ clearInterval(time); function goOn(){ time = setInterval( count() ,1000);//重新設置時間間隔 }

第二個是html資源,為了方便我css直接寫在html中了


 !doctype html  html  head  meta charset= UTF-8  title Document /title  script src= 1.js /script  script src= jquery-1.8.3.min.js /script  style type= text/css  input{ background-color: #9fc5f1; width: 100px;  height: 30px;  line-height: 30px;  text-align: center;  color: #fff;  font-size:14px;  font-weight: bold; #time p{ color: #1f6dc2; font-size: 48px;  font-weight: bold; margin-left:90px; margin-bottom:0px; /style  link rel= stylesheet href= https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css integrity= sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u crossorigin= anonymous  body  div id= time  p 00:00 /p  input type= button value= 開始 quot;start() /  input type= button value= 暫停 quot;pause() /  input type= button value= 繼續 quot;goOn() /  /div  /body  /html 

以上就是html 和js 中實現倒計時功能的詳細內容,html教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 都昌县| 大庆市| 梨树县| 浦城县| 抚顺市| 卓尼县| 方城县| 江城| 和顺县| 集贤县| 柯坪县| 湘潭市| 乐都县| 科尔| 武川县| 兰西县| 蕉岭县| 松溪县| 平利县| 深泽县| 临朐县| 安泽县| 绵阳市| 宁津县| 铁岭县| 石河子市| 金阳县| 太湖县| 安仁县| 洛隆县| 土默特左旗| 河北省| 顺平县| 宜兴市| 乌拉特中旗| 金昌市| 海宁市| 乐清市| 平原县| 伊川县| 巢湖市|