Goal
Modify the previous script, adding the ability to toggle the visibility of multiple fields.
Project
View Source
(function() {
let elPasswords = document.querySelectorAll( "input[type='password']" );
let elShowPasswords = document.querySelector( "#show-passwords" );
elShowPasswords.addEventListener( "input", e =>
{
let inputType = e.target.checked ? "text" : "password";
elPasswords.forEach( elPassword => elPassword.setAttribute( "type", inputType ) );
});
})();
Projects
- Toggle Password Visibility
- Toggle Multiple Password Fields
- Toggle Passwords in Multiple Forms
- Character Count
- Character and Word Count
- Announcing the Count
- Random Ron
- Random Ron Without Duplicates
- New York Times Top Stories
- New York Times Multiple Categories
- Sanitizing the NYT API Data
- Monster Shuffle