2024-08-16 13:01:04 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Scope & parameter</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="output"></div><br>
|
2024-08-16 14:01:43 +02:00
|
|
|
<button onclick="setNum(16)">Set Number to 16</button>
|
|
|
|
<button onclick="setNum(47)">Set Number to 47</button>
|
|
|
|
<button onclick="increaseNum()">Increase number by 1</button>
|
2024-08-16 13:01:04 +02:00
|
|
|
<br><br>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var outputDiv = document.getElementById('output');
|
|
|
|
var numToShow = 0;
|
|
|
|
|
|
|
|
function setNum(selectedNum){
|
|
|
|
numToShow = selectedNum;
|
|
|
|
outputDiv.innerHTML = numToShow;
|
|
|
|
}
|
2024-08-16 14:01:43 +02:00
|
|
|
function increaseNum(){
|
|
|
|
numToShow++;
|
|
|
|
outputDiv.innerHTML = numToShow;
|
|
|
|
}
|
2024-08-16 13:01:04 +02:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|