-
Notifications
You must be signed in to change notification settings - Fork 8
/
Array.from_Animation.html
44 lines (39 loc) · 1.21 KB
/
Array.from_Animation.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>page</title>
<link rel="stylesheet" type="text/css" href="Array.from Animation.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"
/>
</head>
<body>
<div class="container">
<h2>Array.from</h2>
<input type="text" id="text" placeholder="text...." />
<button onclick="myFunction()">CLICK</button>
<div class="boxes"></div>
</div>
<script>
function myFunction() {
let text = document.getElementById("text").value;
let boxes = document.querySelector(".boxes");
let list = Array.from(text);
list.forEach(function (x) {
let box = document.createElement("div");
box.setAttribute("class", "box");
let txt = document.createTextNode(x);
box.appendChild(txt);
document.querySelector(".boxes").appendChild(box);
});
for (let i = 0; i < 3; i++) {
let line = document.createElement("br");
boxes.appendChild(line);
}
}
</script>
</body>
</html>