Created
May 6, 2020 15:36
-
-
Save parzibyte/ebaf5c299ba3b38cab2b6459c86e7ebd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// parzibyte.me/blog | |
const $miCheckbox = document.querySelector("#miCheckbox"), | |
/** | |
* Los siguientes elementos son botones; no tienen que | |
* ver con el checkbox, solo son para el ejemplo | |
*/ | |
$btnMarcar = document.querySelector("#marcar"), | |
$btnDesmarcar = document.querySelector("#desmarcar"), | |
$btnVerEstado = document.querySelector("#verEstado"); | |
$btnMarcar.addEventListener("click", () => { | |
$miCheckbox.checked = true; | |
}); | |
$btnDesmarcar.addEventListener("click", () => { | |
$miCheckbox.checked = false; | |
}); | |
$btnVerEstado.addEventListener("click", () => { | |
if ($miCheckbox.checked) { | |
alert("Marcado"); | |
} else { | |
alert("Desmarcado"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment