-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21_done.html
More file actions
55 lines (46 loc) · 1.34 KB
/
21_done.html
File metadata and controls
55 lines (46 loc) · 1.34 KB
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
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.blok {
width: 60px;
height: 20px;
background-color: red;
margin: 5px;
float: left;
}
</style>
</head>
<body>
<h1>Bouw een muur</h1>
<label for="">Totaal stenen</label>
<input type="text" name="" id="stenen">
<label for="">Lengte in meters</label>
<input type="text" name="" id="meter">
<button onclick="bereken()">Bereken</button><br>
<label for="" id="text">Jou muur: 0 stenen</label>
<div id="muur"></div>
<script>
let muur = document.getElementById('muur')
let text = document.getElementById('text')
let bereken = () => {
muur.innerHTML = ""
let stenen = document.getElementById('stenen').value;
let meter = document.getElementById('meter').value;
let totaal = stenen / meter;
text.innerHTML = `Jou muur: ${totaal} stenen`
for (let index = 0; index < totaal; index++) {
// Now create and append to iDiv
var innerDiv = document.createElement('div');
innerDiv.className = 'blok';
// The variable iDiv is still good... Just append to it.
muur.appendChild(innerDiv);
}
}
</script>
</body>
</html>