Show/Hide Text on Button Click
JavaScript
Easy
3 views
Problem Description
You have a button #btn and a text box #box. On click, toggle #box display between block and none.
Output Format
No output (DOM change).
Constraints
Assume HTML has elements with ids btn and box.
Official Solution
const btn=document.getElementById('btn');const box=document.getElementById('box');btn.addEventListener('click',()=>{box.style.display=(box.style.display==='none')?'block':'none';});
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!