Como - Exibir texto quando a caixa de seleção está marcada
Verifique se uma caixa de seleção está marcada com JavaScript.
Exiba algum texto quando a caixa de seleção estiver marcada:
Caixa de seleção:Verificar se uma caixa de seleção está marcada
Etapa 1) Adicionar HTML:
Exemplo
Checkbox: <input type="checkbox" id="myCheck" onclick="myFunction()">
<p id="text" style="display:none">Checkbox is CHECKED!</p>
Etapa 2) Adicionar JavaScript:
Exemplo
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";
}
}