How to prevent checkbox from being unchecked in JavaScript
In this article, you are going to learn how you can prevent a checkbox from being unchecked using JavaScript preventDefault() method without disableing it.
Prevent checkbox from being checked
<input checked="" type="checkbox" id="my-checkbox">
<script>
document.querySelector('#my-checkbox').onclick = (e)=>{
e.preventDefault();
}
</script>
Try it Yourself »
Use the preventDefault() method to stop the default behavior of a particular element. Learn more about preventDefault() method.
save
listen
AI Answer
How to prevent checkbox from being unchecked in JavaScript
0
In this article, you are going to learn how you can prevent a checkbox from being uncheck…
asked
Apu
0 answers
2915
In this article, you are going to learn how you can prevent a checkbox from being uncheck…
Answer Link
answered
Apu
