This commit is contained in:
Philippe Torrel
2026-08-19 11:41:58 +02:00
parent c6d9611e81
commit ae9b04f27f
111 changed files with 3878 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@@ -25,18 +25,33 @@
'use strict';
(() => {
// === DOM & VARS =======
const DOM = {};
// ===== DOM & VARS =====
const countEl = document.querySelector('#count');
const btnEl = document.querySelector('#incrementButton');
// === INIT =============
const init = () => {};
let counter = { count: 0 };
// === EVENTHANDLER =====
// ===== INIT =====
const init = () => {
btnEl.addEventListener('click', onClickIncrement);
};
// === XHR/FETCH ========
// ===== EVENT HANDLER =====
function onClickIncrement() {
// variante 1
// let count = counter.count;
// count++;
// counter = { count: count };
// === FUNCTIONS ========
// Variante 2
// counter = { count: ++counter.count }; // hier ist der präfix-inkrement wichtig - der post-inkrement würde ins "leere" gehen, da er erst zugewiesen wird und dann erhöht und diese somit verloren ginge
// Variante 3 - direkt counter.count erhöhren
counter.count++;
countEl.value = counter.count;
}
// ===== CALL INIT =====
init();
})();
</script>