Demo: Alternate Between Two Div Layers

Message Box 4

← tutorial on show hide layer

JavaScript Top ↑

const button=document.getElementById('bt1');
const box3=document.getElementById('sub3');
const box4=document.getElementById('sub4');
button.addEventListener('click',()=>{
  const show3=box3.hidden;
  box3.hidden=!show3;
  box4.hidden=show3;
  button.textContent=show3?'Show Box 4':'Show Box 3';
});

HTML Top ↑

<button type="button" id="bt1">Show Box 3</button>
<div id="sub3" hidden>Message Box 3</div>
<div id="sub4">Message Box 4</div>



Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer