<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)

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.