<input type='password' id='password'/>
<p>
Show Password
<input type='checkbox' id='checkbox'/>
</p>
const myInput = document.querySelector('#password')
const checkbox = document.querySelector('#checkbox')
const toggleVisibility = ()=>{
if (myInput.type === "password") {
myInput.type = "text";
} else {
myInput.type = "password";
}
}
checkbox.addEventListener('change', toggleVisibility)
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.