mam kod który po zaznaczeniu checkboxa pokazuje div, ale potem go nie ukrywa. jak to poprawić?
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";
}
}
choroba: <input type="checkbox" id="myCheck" onclick="myFunction()">
brak choroby: <input type="checkbox">
<p id="text" style="display:none">Checkbox is CHECKED!</p>