✍
<script type="text/javascript">
function innText(){
let now = new Date();
document.getElementById("currentTimeText").innerText = "<h3>" + now + "</h3>";
}
function innHtml(){
let now = new Date();
document.getElementById("currentTimeHtml").innerHTML = "<h3>" + now + "</h3>";
// alert(document.getElementById("currentTimeHtml"));
}
</script>
</head>
<body>
<h1>test31.html</h1>
<button onclick="innText()">innerText로 표시하기</button>
<button onclick="innHtml()">innerHtml로 표시하기</button>
<hr>
<h1>현재 시각 Text</h1>
<div id="currentTimeText"></div>
<hr>
<h1>현재 시각 Html</h1>
<div id="currentTimeHtml"></div>
</body>
💻
'개발 > Javascript' 카테고리의 다른 글
[Javascript] 20230117 (0) | 2023.01.17 |
---|---|
[Javascript] 이미지 경로 (0) | 2023.01.14 |
[Javascript] location 객체 (0) | 2023.01.14 |
[Javascript] history 객체 (0) | 2023.01.14 |
[Javascript] pop up () (0) | 2023.01.14 |