JSFiddle - React, Tailwind, and code Playground

by Nikola Mihin

HTML

<html>

  <body>

    <p>I want the code to be something like this</p>

    <label for="check-1a">This is for item 1a</label>
    <input type="checkbox" id="check-1a" onclick="myFunction()">

    <div id="text-1a" style="display:none">
      <p>Div with HTML content of div for 1a is displayed</p>
    </div>

    <script>
      function myFunction() {
        var checkBox = document.getElementById("check-1a");
        var text = document.getElementById("text-1a");
        if (checkBox.checked == true) {
          text.style.display = "block";
        } else {
          text.style.display = "none";
        }
      }

    </script>

  </body>

</html>