-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtig.html
More file actions
52 lines (51 loc) · 1.36 KB
/
Copy pathtig.html
File metadata and controls
52 lines (51 loc) · 1.36 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>11.18日</title>
<style>
.add,.exc{
line-height: 25px;
outline: none;
border: 1px solid cornflowerblue;
background: pink;
border-radius: 10px;
}
.one{
width: 300px;
height: 40px;
margin: auto;
margin-top: 20px;
}
.btn-div,.aut-div{
width: 300px;
height: 208px;
border:1.5px solid red;
margin: auto;
margin-top: 20px;
}
</style>
</head>
<body>
<div class="one">
<button class="add" onclick="addDomappendChild()">通过appendChild添加</button>
<button class="exc" onclick="addDominnerHTML()">通过innerHTML添加</button>
</div>
<div class="btn-div" id="cher1"></div>
<div class="aut-div" id="cher2"></div>
<script>
function addDomappendChild() {
var dom = document.getElementById("cher1");
var input = document.createElement("input");
input.id ="btn";
input.type = "button";
input.value = "按钮";
dom.appendChild(input);
}
function addDominnerHTML() {
var dom = document.getElementById("cher2");
dom.innerHTML = "<input id=\"btn\" type=\"button\" value=\"按钮\"/>"
}
</script>
</body>
</html>