-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththree.html
More file actions
34 lines (27 loc) · 927 Bytes
/
three.html
File metadata and controls
34 lines (27 loc) · 927 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Create a new Element in DOM</title>
</head>
<body style="background-color:#212121;color:white">
</body>
<script>
const div=document.createElement('div');
console.log(div);
div.className="main" // setting the class name
div.id=Math.round(Math.random()*10+1) // setting the id name
div.setAttribute("title","generated title");
const style=function(div){
div.style.backgroundColor="green";
div.style.borderRadius="18px";
div.innerText = "Div created using JS";
div.innerText="Div created using JS";
div.style.padding="8px";
div.style.display="inline";
}
document.body.appendChild(div); //*** MOST IMPORTANT , without appending to the body nothing will change in the page
style(div);
// div.append("Hello this is for testing purpose!")
</script>
</html>