Answers for "js hide one button and show another"

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

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

Browse Popular Code Answers by Language