<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript">
window.onload = function(){
setInterval(showTime,1000);
};
function showTime() {
var view = document.getElementById("view");
var date = new Date();
view.innerHTML = date.toLocaleTimeString();
}
</script>
</head>
<body>
<h2>현재 시간</h2>
<div id="view"></div>
</body>
</html>
'Web > JavaScript' 카테고리의 다른 글
[JavaScript] 새 창 열기 (0) | 2021.03.07 |
---|---|
[JavaScript] 구구단 출력 (0) | 2021.03.07 |