How to check uncheck checkbox in JavaScript.
<input type="checkbox" name="fruit" value="Mango" /> Mango
I have a CheckBox in the page.
How to check and uncheck checkbox on button click.
Hi Adnaan,
On Button click, check if CheckBox is Checked then set the checked property to false elase true.
Refer below example.
HTML
<html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> body { font-family: Arial; font-size: 10pt; } </style> </head> <body> <input type="checkbox" id="chkMango" value="Mango" /><label for="chkMango">Mango</label> <input type="button" value="Submit" onclick="CheckUncheck()" /> <script type="text/javascript"> function CheckUncheck() { var checkBox = document.getElementById('chkMango'); checkBox.checked = !checkBox.checked } </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.