Answers for "html how to show or hide div on button click"

1

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

hide div on button click javascript

<style>
	function hideDiv(){
		var closedDiv  = document.getElementById("closableDiv");
		closedDiv.style.display = "none";
	}
</style>
<button id="closableDiv" onClick="hideDiv()"> </button>
Posted by: Guest on July-13-2021
0

onclick hide div javascript

<script type="text/javascript">
function hide(id) {
	document.getElementById(id).style.display = "none";
}
function show(id) {
	document.getElementById(id).style.display = "";
}
</script>
<div id="div" onclick="hide('div')">
  <p>Click to hide!</p>
</div>
Posted by: Guest on July-16-2021

Code answers related to "html how to show or hide div on button click"

Browse Popular Code Answers by Language