-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddElements.html
46 lines (42 loc) · 1.14 KB
/
addElements.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adding Elements Using Dom</title>
<style>
body{
width: 100vw;
height: 100vh;
background-color: aqua;
}
</style>
</head>
<body class="bg-black">
</body>
<script>
// let div=document.createElement('div')
// div.innerHTML="Ganesh Ghode"
// // let addText=document.createTextNode("ganesh ghode")
// // div.appendChild(addText)
// div.style.backgroundColor="green"
// div.style.padding="20px"
// document.body.appendChild(div)
function creatBox(colour){
let box=document.createElement('div')
let text=document.createTextNode("Hello Guys")
box.style.padding="20px"
box.style.width="150px";
box.style.height="150px"
box.style.backgroundColor=`${colour}`
box.style.border="3px solid black"
console.log(box.appendChild(text))
text.replaceWith("Ganesh Ghode")
document.body.appendChild(box)
}
creatBox("green")
creatBox("yellow")
creatBox("pink")
creatBox("tomato")
</script>
</html>