Cómo - Mostrar texto cuando la casilla de verificación está marcada
Compruebe si una casilla de verificación está marcada con JavaScript.
Mostrar algo de texto cuando la casilla de verificación está marcada:
Caja:Comprobar si una casilla de verificación está marcada
Paso 1) Agregar HTML:
Ejemplo
Checkbox: <input type="checkbox" id="myCheck" onclick="myFunction()">
<p id="text" style="display:none">Checkbox is CHECKED!</p>
Paso 2) Agregar JavaScript:
Ejemplo
function myFunction() {
// Get the checkbox
var checkBox =
document.getElementById("myCheck");
// Get the output text
var text = document.getElementById("text");
// If the checkbox
is checked, display the output text
if (checkBox.checked == true){
text.style.display = "block";
} else {
text.style.display = "none";
}
}