-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.html
More file actions
39 lines (32 loc) · 902 Bytes
/
array.html
File metadata and controls
39 lines (32 loc) · 902 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
39
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Create an array of elements</title>
<script type="module" src="../src/polyfill.js"></script>
<script type="module">
// Create an array of objects (here, just numbers).
const numbers = [];
for (let i = 0; i < 255; i += 16) {
numbers.push(i);
}
// For each object, create an element.
const elements = numbers.map(number => {
const color = `rgb(${number}, ${number}, ${number})`;
return document.createElement('div', {
style: { color },
textContent: color
});
});
// Apply that array as child nodes of the indicated container.
colors.applyProperties({
childNodes: elements
});
</script>
</head>
<body>
<h1>Colors</h1>
<div id="colors"></div>
</body>
</html>