當前位置:編程學習大全網 - 編程軟體 - javascript,實現壹個時鐘,頁面顯示當前時間包括年月日時 分 秒 並設定壹個時間點,當該

javascript,實現壹個時鐘,頁面顯示當前時間包括年月日時 分 秒 並設定壹個時間點,當該

<html>

<head>

<title>Time</title>

</head>

<body>

<div?id="time"></div>

<div?id="alert"></div>

</body>

<script?type="text/javascript"?charset="utf-8"?async?defer>

var?time?=?document.getElementById("time");

showTime();

function?showTime()?{

//?To?get?the?date?time

var?date?=?new?Date();

var?year?=?date.getYear()?+?1900;

var?month?=?date.getMonth()?+?1;

var?day?=?date.getDate();

var?hour?=?date.getHours();

var?min?=?date.getMinutes();

var?sec?=?date.getSeconds();

var?date_time?=?year?+?"-"?+?month?+?"-"?+?day?+?"?"?+?hour?+?":"?+?min?+?":"?+?sec;

time.innerHTML?=?date_time;

//?when?the?time?is?equal?your?condition,?show?the?special?words.

if(date_time?==?"2014-6-25?11:45:20")?{

document.getElementById("alert").innerHTML?=?"It's?time?to?display?your?words?here.";

}

}

//?set?the?interval?time

setInterval(showTime,?1000);

</script>

</html>

  • 上一篇:適合團建的遊戲
  • 下一篇:誰有編程作品
  • copyright 2024編程學習大全網