little more from the mvc chapter
This commit is contained in:
parent
cafa3b8957
commit
12dc3057b6
6 changed files with 74 additions and 12 deletions
|
@ -1,13 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Model View Controller</title>
|
||||
<style>
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
|
@ -17,16 +19,24 @@
|
|||
|
||||
// view
|
||||
updateView();
|
||||
function updateView(){
|
||||
function updateView() {
|
||||
let question;
|
||||
if (questionIndex == 0) question = "Hva er 2 + 2 ?"
|
||||
else if (questionIndex == 1) question = "Hva er hovedstaden i Sverige ?"
|
||||
|
||||
document.getElementById('app').innerHTML = /*HTML*/ `
|
||||
<h1></h1>
|
||||
<h1>${question}</h1>
|
||||
Poeng: ${points}<br>
|
||||
<input type="text">
|
||||
<button onclick="next()">Next</button>
|
||||
`;
|
||||
};
|
||||
// controller
|
||||
function next() {
|
||||
questionIndex++;
|
||||
updateView();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue