This commit is contained in:
Philippe Torrel
2026-08-18 14:27:34 +02:00
parent c7d26e1cd9
commit c6d9611e81
35 changed files with 1852 additions and 130 deletions

View File

@@ -0,0 +1,51 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Counter Example</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="container py-5">
<h1>Counter</h1>
<div class="row mt-4">
<div class="col col-12 col-sm-10 col-lg-6">
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">Count:</span>
<input type="text" id="count" class="form-control" value="0" readonly />
</div>
<button id="incrementButton" class="btn btn-primary w-100">Increment</button>
</div>
</div>
</div>
<script>
'use strict';
(() => {
// ===== DOM & VARS =====
const countEl = document.querySelector('#count');
const btnEl = document.querySelector('#incrementButton');
let counter = { count: 0 };
// ===== INIT =====
const init = () => {
btnEl.addEventListener('click', onClickIncrement);
};
// ===== EVENT HANDLER =====
function onClickIncrement() {
let count = counter.count;
count++;
countEl.value = counter.count;
}
// ===== CALL INIT =====
init();
})();
</script>
</body>
</html>