seenfil
Back to feed

How to check a checkbox in JS

CODE
<input type="checkbox" id="myCheckbox" />
<button onclick="checkCheckbox()">Check</button>

<script>
  function checkCheckbox() {
    const checkbox = document.getElementById('myCheckbox');
    if (checkbox.checked) {
      console.log('Checkbox is checked');
    } else {
      console.log('Checkbox is not checked');
    }
  }
</script>
528
Comments (2)
HELLO
Please, you should get in touch with me via this email ( salimota.22t AT gmail (.) com ) for more information about me
Log in to leave a comment.
Photo
1 / 1
likes
❤️ 🔥 😂 😍 👍 👏 🎉 🚀 🥳 💯

Create Post

You are not a member of any community yet. Posts can only be published in communities you have joined. Browse Communities