startit/MVC/løkker.html

45 lines
1,020 B
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
</div>
<script>
// Model
let maxNumber = 10;
// view
updateView();
function updateView() {
let lishtml = '';
for (let i = 1; i <= maxNumber; i++) {
lishtml += /*HTML*/ `
2024-09-06 14:34:17 +02:00
<li>${maxNumber} x ${i} = ${i * maxNumber}</li>
`;
}
document.getElementById('app').innerHTML = /*HTML*/`
<h1>App</h1>
<input
style="font-size:300%;"
type="number" min="1" step="1" max="100";
oninput="maxNumber=this.valueAsNumber; updateView();"
value="${maxNumber}"
/>
<ul>
${lishtml}
</ul>
`;
}
</script>
</body>
</html>