範例:勾選同意後,則顯示物件
<input type="checkbox" id="myCheck" onclick="myFunction()"> <label for="myCheck">我已詳閱並同意</label>
<script>
function myFunction() {
var checkBox = document.getElementById("myCheck");
var text = document.getElementById("hidebtn");
if (checkBox.checked == true){
text.style.display = "block";
} else {
text.style.display = "none";
}
}
</script>
其他CSS應用
pointer-events: none;
JS內可寫作
text.style.pointerEvents = "none";