Home > Web Front-end > JS Tutorial > body text

How to determine whether a certain item is checked in js

anonymity
Release: 2019-05-29 11:36:41
Original
3494 people have browsed it

js determines whether input checked is selected code example

checked attribute sets or returns whether the checkbox should be selected.

How to determine whether a certain item is checked in js

Syntax

checkboxObject.checked=true|false
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!