Answers for "javascript show hide element by buttom"

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
0

how to make hide/show btn in js

let btnName = document.getElementById('btnId');
btnName.addEventListener('click', ()=>{
  let element = document.getElementById('elementId');
	if (element.style.display != 'inline'){
    	element.style.display = 'inline';
    }
  else{
    element.style.display = 'none'
  }
})
Posted by: Guest on July-13-2021

Code answers related to "javascript show hide element by buttom"

Browse Popular Code Answers by Language