Javascript examples for DOM HTML Element:Input Checkbox
Input Checkbox checked Property - Find out if a checkbox is checked or not:
<!DOCTYPE html> <html> <body> Checkbox: <input type="checkbox" id="myCheck"> <button onclick="check()">Check Checkbox</button> <button onclick="uncheck()">Uncheck Checkbox</button> <script> function check() {// ww w .ja va 2 s. c o m document.getElementById("myCheck").checked = true; var v = document.getElementById("myCheck").checked; console.log(v); } function uncheck() { document.getElementById("myCheck").checked = false; var v = document.getElementById("myCheck").checked; console.log(v); } </script> </body> </html>