Answers for "html show and hide content on click of button"

5

html button that hide and show

<button onclick="toggleText()">button</button>
<p id="Myid">Text</p>
<script>
function toggleText(){
  var x = document.getElementById("Myid");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
</script>
Posted by: Guest on October-17-2020
0

JS Show/hide when button is clicked

var toggle  = document.getElementById("toggle");
var content = document.getElementById("content");

toggle.addEventListener("click", function() {
  content.classList.toggle("show");
});
Posted by: Guest on November-25-2021

Code answers related to "html show and hide content on click of button"

Browse Popular Code Answers by Language