How to check uncheck checkBox on Button click in JavaScript?
<input type="checkbox" id="chkMango" value="Mango" /><label for="chkMango">Mango</label> <input id="btnCheckUncheck" type="button" value="Submit" />
Hi Adnaan,
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 id="btnCheckUncheck" type="button" value="Submit" onclick="CheckUncheck()" /> <script type="text/javascript"> function CheckUncheck() { document.getElementById("chkMango").checked = !document.getElementById("chkMango").checked; } </script> </body> </html>
Demo
Screenshot
Downloads
Download Sample
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.