i trying to change css using java script but it did not work.
function myFunction() {
var x = document.getElementsByClassName('chirag');
var check = document.getElementById('chk1');
for (var i=0;i<x.length;i+=1){
if(check.checked){
x.style.display = 'none';
}
else {
x.style.display = 'block';
}
}
}
.chirag{
display: none;
}
<input type="checkbox" id="chk1" value="Plate" onclick="myFunction()"> Plate <br>
<div id="plan_detail" class="chirag">
</div>
i try to add javascript function on checkbox event. how can i fix it and change the css property
xis a list of elements, not an element itself. Maybe you meantx[i].style.display?