html
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
<!DOCTYPE html>
<html>
<head>
<title>div/timer</title>
</head>
<body>
</body>
<script>
// 1. Create a div dynamically with javascript, give it a unique id and class
var mainDiv = document.createElement("div");
mainDiv.id = "main-div";
mainDiv.className = "main";
mainDiv.style.backgroundColor = "gray";
mainDiv.style.color = "white";
mainDiv.style.textAlign = "center";
mainDiv.style.position = "absolute";
mainDiv.style.top = "80px";
mainDiv.style.left = "80px";
mainDiv.style.width = "100%";
mainDiv.style.height = "100%";
mainDiv.style.overflow = "scroll";
document.body.appendChild(mainDiv);
// 2. Inside this div create nine other child divs, give them unique id and class, also let all their innerhtml be number 0 to nine according to the loop.
for (var i = 0; i < 10; i++) {
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
body {
}
Enter to Rename, Shift+Enter to Preview
js
js
1
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run