const button=document.getElementById('bt1');
const boxes=[document.getElementById('sub3'),document.getElementById('sub4')];
button.addEventListener('click',()=>{
const show=boxes[0].hidden;
boxes.forEach((box)=>{box.hidden=!show;});
button.textContent=show?'Hide Layer':'Show Layer';
button.setAttribute('aria-expanded',String(show));
});
<button type="button" id="bt1" aria-expanded="false">Show Layer</button>
<div id="sub3" hidden>Message Box 3</div>
<div id="sub4" hidden>Message Box 4</div>
#sub3,#sub4{background-color:#f1f1f1;width:280px;padding:10px;color:#000;border:2px dashed #0000cc;margin-top:1rem;}
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.