|
|
|
|
|
by simonw
1799 days ago
|
|
var checkbox = document.querySelector(
"input[type=checkbox]"
), container = document.querySelector(
"#wrapper"
);
checkbox.addEventListener("change", () => {
if (checkbox.checked) {
container.classList.add("checked");
} else {
container.classList.remove("checked");
}
});
Then use CSS to show or hide the message inside the container based on if it has class "checked" or not.You can get a whole lot done with very little code if you learn to take advantage of the three-legged stool of HTML, CSS and JavaScript. |
|