js determines whether input checked is selected code example
checked attribute sets or returns whether the checkbox should be selected.
Syntax
checkboxObject.checked=true|false
This attribute saves the current state of the checkbox. Whenever this value changes, onclick The event handler will be triggered (the onchange event handler may also be triggered).
Example
The following example can set the status of the checkbox:
<html> <head> <script type="text/javascript"> function check() { document.getElementById("check1").checked=true } function uncheck() { document.getElementById("check1").checked=false } </script> </head> <body> <form> <input type="checkbox" id="check1" /> <input type="button" onclick="check()" value="Check Checkbox" /> <input type="button" onclick="uncheck()" value="Uncheck Checkbox" /> </form> </body> </html>
The above is the detailed content of How to determine whether a certain item is checked in js. For more information, please follow other related articles on the PHP Chinese website!