Toggle Password Visibility
JavaScript
Easy
3 views
Problem Description
You have and . On click, change input type between password and text, and update button text to SHOW/HIDE.
Output Format
No output (DOM change).
Constraints
Assume #pwd input and #toggle button exist.
Official Solution
const pwd=document.getElementById('pwd');const toggle=document.getElementById('toggle');const upd=()=>{toggle.textContent=pwd.type==='password'?'SHOW':'HIDE';};toggle.addEventListener('click',()=>{pwd.type=pwd.type==='password'?'text':'password';upd();});upd();
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!