-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom8.html
More file actions
38 lines (35 loc) · 903 Bytes
/
dom8.html
File metadata and controls
38 lines (35 loc) · 903 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="em">
<head>
<script>
const sum=function(x=0,y=0,z=0){//default params
return x+y+z;
}
</script>
<title>DOM</title>
</head>
<body>
<h3>demo on removing & adding elements</h3>
<div id="div1">
<h2>Apple</h2>
<span>Mango</span>
<p>Orange</p>
<button onclick="document.querySelector('h2').remove()">delete element</button>
</div>
<div id="div2">
<button id="bt2"> add element </button>
</div>
<script>
document.querySelector("#bt2").onclick=()=>{
const i=document.createElement("img");
i.src="bike.jpg";
i.style.width="200px";
i.style.height="160px";
i.style.borderRadius="10px";
i.style.margin="5px";
// document.body.appendChild(i);
document.querySelector("span").appendChild(i);
}
</script>
</body>
</html>