JSFiddle - React, Tailwind, and code Playground

by Alphonsio

HTML

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

CSS

* {
  background-color: #eee;
 }
 
 #output {
   margin-top: 1rem;
 }

JavaScript

function checkCheckbox() {
      const checkbox = document.getElementById('myCheckbox');
      if (checkbox.checked) {
          document.getElementById("output").textContent = 'The checkbox is checked!'
      } else {
          document.getElementById("output").textContent = 'The checkbox is not checked!';
      }
  }