← tutorial on show hide layer Demo using two buttons →
const button=document.getElementById('bt1');
const box=document.getElementById('sub3');
button.addEventListener('click',()=>{
box.hidden=!box.hidden;
const visible=!box.hidden;
button.textContent=visible?'Hide Layer':'Show Layer';
button.setAttribute('aria-expanded',String(visible));
});
<button type="button" id="bt1" aria-expanded="false">Show Layer</button>
<div id="sub3" hidden>Message Box</div>
#sub3{background-color:#f1f1f1;width:280px;padding:10px;color:#000;border:2px dashed #0000cc;}
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.