JSFiddle - React, Tailwind, and code Playground

by shahryar saljoughi

HTML

<!DOCTYPE html>
<html>
<head>
<style>
#panel, .flip {
  font-size: 16px;
  padding: 10px;
  text-align: center;
  background-color: #4CAF50;
  color: white;
  border: solid 1px #a6d8a8;
  margin: auto;
}

#panel {
  display: none;
}
</style>
</head>
<body>

<p class="flip" onclick="myFunction()">Click to show panel</p>

<div id="panel">
  <p>This panel contains a div element, which is hidden by default (display: none).</p>
  <p>It is styled with CSS and we use JavaScript to show it (display: block).</p>
  <p>How it works: Notice that the p element with class="flip" has an onclick attribute attached to it. When the user clicks on the p element, a function called myFunction() is executed, which changes the style of the div with id="panel" from display:none (hidden) to display:block (visible).</p>
  <p>You will learn more about JavaScript in our JavaScript Tutorial.</p>
  <p class="flip" onclick="myFunction2()">Click to hide panel</p>
</div>

<p>This is some text after the panel whose display property's value may change.</p>

<script>
function myFunction() {
  document.getElementById("panel").style.display = "block";
}
function myFunction2() {
  document.getElementById("panel").style.display = "none";
}
</script>

</body>
</html>