Answers for "javascrioy hide dispay on click"

2

onclick hide div javascript

<div id="div">
	<p>Click to hide!</p>
</div>
<script type="text/javascript">
	const div = document.getElementById("div");
	div.addEventListener("click", function() {
		// hide element: element.hidden = true;
		// show element: element.hidden = false;
		div.hidden = true;
	});
</script>
Posted by: Guest on July-16-2021
1

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

Browse Popular Code Answers by Language