最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

JS復(fù)習(xí)作業(yè):Date等函數(shù)題,倒計(jì)時(shí),鐘表,自定義毫秒轉(zhuǎn)化為時(shí)間【詩書畫唱】

2020-06-17 08:48 作者:詩書畫唱  | 我要投稿

案例:通過Date函數(shù)寫一個(gè)得到當(dāng)前時(shí)間的函數(shù),格式為“2222年02月11日?11:09:01?星期3”



var dangQian=new Date();


var year=dangQian. getFullYear();


var month=dangQian. getMonth()+1;


var day=dangQian. getDate();


var zhouji=dangQian. getDay();


var xiaoshi=dangQian . getHours();


var fenzhong=dangQian . getMinutes();


var miao=dangQian. getSeconds();


var divJieMianVar=document . getElementById("divJieMian");



divJieMianVar. innerHTML="當(dāng)前時(shí)間為"+year+"年"+month+"月"+day+"日"+xiaoshi+":"+fenzhong+":"+miao;




得到當(dāng)前時(shí)間,打印當(dāng)前時(shí)間的毫秒數(shù)





<!DOCTYPE html>


<html>


<head>


<meta charset="utf-8" />


<title></title>


<script>


window. onload=function(){



var dangQian=new Date();


var year=dangQian. getFullYear();


var month=dangQian. getMonth()+1;


var day=dangQian. getDate();


var zhouji=dangQian. getDay();


var xiaoshi=dangQian . getHours();


var fenzhong=dangQian . getMinutes();


var miao=dangQian. getSeconds();


var divJieMianVar=document . getElementById("divJieMian");


var zongMiaoShuCha=?


? ? parseInt(dangQian.getTime()) ;


divJieMianVar. innerHTML="當(dāng)前時(shí)間為"+year+"年"

+month+"月"+day+"日"+xiaoshi+":"+fenzhong+":"+miao+";當(dāng)前時(shí)間轉(zhuǎn)換毫秒數(shù)為"+zongMiaoShuCha+"毫秒";


}


</script>


</head>


<body>


<div id="divJieMian"></div>


</body>


</html>



<!DOCTYPE html>


<html>


<head>


<meta charset="utf-8" />


<title></title>


<script>


window. onload=function(){



var dangQian=new Date();


var year=dangQian. getFullYear();


var month=dangQian. getMonth()+1;


var day=dangQian. getDate();


var zhouji=dangQian. getDay();


var xiaoshi=dangQian . getHours();


var fenzhong=dangQian . getMinutes();


var miao=dangQian. getSeconds();


var divJieMianVar=document . getElementById("divJieMian");


var zongMiaoShuCha=?


? ? parseInt(dangQian.valueOf()) ;


divJieMianVar. innerHTML="當(dāng)前時(shí)間為"+year+"年"

+month+"月"+day+"日"+xiaoshi+":"+fenzhong+":"+miao

+";當(dāng)前時(shí)間轉(zhuǎn)換毫秒數(shù)為"+zongMiaoShuCha+"毫秒";


}


</script>


</head>


<body>


<div id="divJieMian"></div>


</body>


</html>




聲明一個(gè)變量10000000,將該毫秒傳入到時(shí)間中,打印該時(shí)間




<!DOCTYPE html>


<html>


<head>


<meta charset="utf-8" />


<title></title>


<script>


window. onload=function(){


var s=10000000

var dangQian=new Date(s);


var year=dangQian. getFullYear();


var month=dangQian. getMonth()+1;


var day=dangQian. getDate();


var zhouji=dangQian. getDay();


var xiaoshi=dangQian . getHours();


var fenzhong=dangQian . getMinutes();


var miao=dangQian. getSeconds();


var divJieMianVar=document . getElementById("divJieMian");



divJieMianVar. innerHTML="當(dāng)前時(shí)間為"+year+"年"

+month+"月"+day+"日"+xiaoshi+":"+fenzhong+":"+miao;


}


</script>


</head>


<body>


<div id="divJieMian"></div>


</body>


</html>


案例:將上個(gè)例子改寫為一個(gè)時(shí)鐘

<!DOCTYPE html>


<html>


<head>


<meta charset="utf-8" />


<title></title>


<script>


window. onload=function(){



setInterval(shiZhongFunction,1000);}


function shiZhongFunction(){


var dangQian=new Date();


var year=dangQian. getFullYear();


var month=dangQian. getMonth()+1;


var day=dangQian. getDate();


var zhouji=dangQian. getDay();


var xiaoshi=dangQian . getHours();


var fenzhong=dangQian . getMinutes();


var miao=dangQian. getSeconds();


var divJieMianVar=document . getElementById("divJieMian");


divJieMianVar. innerHTML="當(dāng)前時(shí)間為"+year+"年"

+month+"月"+day+"日"+xiaoshi+":"+fenzhong+":"+miao;


}


</script>


</head>


<body>


<div id="divJieMian"></div>


</body>


</html>





案例:寫一個(gè)倒計(jì)時(shí)


<!DOCTYPE html>


<html>


<head>


<meta charset="utf-8" />


<title></title>


<script>


var i;


function daoJishiFunction(){

if(i==0){


alert("倒計(jì)時(shí)結(jié)束,"+"倒計(jì)時(shí)還有"+i+"秒");


?zanTing();


}


var div1=document . getElementById("div1");


div1. innerHTML="倒計(jì)時(shí)還有"+i+"秒";


i--;




}




var jieshou=null;


function start(){


if(jieshou==null){


jieshou=setInterval(daoJishiFunction, 1000);


}}



function zanTing(){


clearInterval(jieshou);


jieshou=null;


}


window . onload=function(){


i=prompt("請(qǐng)輸入倒計(jì)時(shí)的時(shí)間");


}


</script>


</head>


<body>




<div id="div1"></div>


<input type= "button" id= "btn1" value="開始倒計(jì)時(shí)"onclick= "start()" />


<input type= "button" id= "btn2" value="暫 停" onclick="zanTing()" />


</body>


</html>


這里顯示為1,但實(shí)際上已經(jīng)為0秒:



JS復(fù)習(xí)作業(yè):Date等函數(shù)題,倒計(jì)時(shí),鐘表,自定義毫秒轉(zhuǎn)化為時(shí)間【詩書畫唱】的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
杭州市| 乌苏市| 京山县| 石城县| 景洪市| 张家港市| 洛隆县| 揭西县| 临颍县| 陇川县| 江西省| 南溪县| 兴业县| 团风县| 阿拉尔市| 平泉县| 临高县| 铁力市| 平凉市| 麻江县| 德清县| 灵石县| 犍为县| 新昌县| 海兴县| 南涧| 双鸭山市| 策勒县| 灯塔市| 桐梓县| 荃湾区| 宁化县| 纳雍县| 虎林市| 河南省| 延安市| 兴安盟| 洛宁县| 宜宾市| 南宫市| 齐齐哈尔市|