🍦 Vanilla JavaScript

Projects for the Vanilla JS Academy

Day 1

Toggle Password Visibility

Goal

Write a script that lets users toggle the visibility of a password field.

Project

View Source
(function() {
	let elPassword = document.querySelector( "#password" );
	let elShowPassword = document.querySelector( "#show-password" );
	elShowPassword.addEventListener( "input", e =>
	{
		let inputType = e.target.checked ? "text" : "password";
		elPassword.setAttribute( "type", inputType );
	});
})();