<html>
<body>
<h1>Checkbox activation</h1>
<label id="bare-label">
<input type="checkbox" id="bare" aria-label="Bare checkbox">
<span>Bare checkbox</span>
</label>
<div id="bare-out"></div>
<script>
const bare = document.getElementById("bare");
const bareOut = document.getElementById("bare-out");
const seen = [];
for (const name of ["click", "input", "change"]) {
bare.addEventListener(name, () => {
seen.push(name + ":" + bare.checked);
bareOut.textContent = "";
const heading = document.createElement("h2");
heading.textContent = "Bare saw " + seen.join(",");
bareOut.appendChild(heading);
});
}
</script>
</body>
</html>