사용자입력받기.html
859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>123</title>
</head>
<body>
<button type="button" onclick = "myFunction()" name="button">click this</button>
<div id="div1">
<h1>안녕하세요</h1>
</div>
<input type="text" name="" value="" id="input1">
<button type="button" onclick="myFunction2()" name="button">click this</button>
<div id="div2">
</div>
<script type="text/javascript">
"use strict";
function myFunction(){
var name = prompt("Enter your Name", "Name");
var t = document.getElementById("div1");
t.innerHTML = "<h1>"+name+"</h1>";
}
function myFunction2(){
var name = document.getElementById("input1").value;
var div = document.getElementById("div2");
div.innerHTML = "<h1>"+name+"</h1>";
}
</script>
</body>
</html>