-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhtml9.html
56 lines (43 loc) · 1.03 KB
/
html9.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
48
49
50
51
52
53
54
55
56
<!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">
var heading = document.getElementById('h');
console.log(h);
heading.setAttribute('align','center');
console.log(heading.getAttribute('align'));
heading.innerHTML ="Hello" ;
var p = document.getElementsByTagName('p');
for (i in p)
console.log(p[i]);
p[0].innerHTML = "paragraph 1"
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');
let newLi1 = document.createElement('li');
newLi.innerHTML = "add new list1"+i;
newLi1.innerHTML = "add new list2"+i;
ul.appendChild(newLi)
ul.appendChild(newLi1)
i++;
}
</script>
</body>
</html>