Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created May 6, 2020 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/ebaf5c299ba3b38cab2b6459c86e7ebd to your computer and use it in GitHub Desktop.
Save parzibyte/ebaf5c299ba3b38cab2b6459c86e7ebd to your computer and use it in GitHub Desktop.
// 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