forked from samchampkittisak/htmlex1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml10.html
47 lines (35 loc) · 782 Bytes
/
html10.html
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
<!DOCTYPE html>
<html>
<head>
<title> Hello world </title>
</head>
<body>
<h1 id="h">Heading</h1>
<p>This is a paragraph 1</p>
<p>This is a paragraph 2</p>
<div>
<h2> This is h2 </h2>
</div>
<ul id="ul">
<li> list 1 </li>
<li> list 2 </li>
</ul>
<button onclick="addItem()"> Click </button>
<script type="text/javascript">
let h1 = document.getElementById('h');
h1.onclick = function () {
// change text to hello world
h1.innerHTML = "Hello world"
}
var li = document.getElementsByTagName('li');
for (i in li)
li[i].innerHTML ="new list" + (Number(i)+1);
var ul = document.getElementById('ul');
addItem = () => {
let newLi = document.createElement('li');
newLi.innerHTML = "add new list"
ul.appendChild(newLi)
}
</script>
</body>
</html>