javascript
Published on January 26, 2024By DeveloperBreeze
// Get references to the password input and toggle button
const passwordInput = document.getElementById('passwordInput');
const toggleButton = document.getElementById('toggleButton');
// Add event listener to the toggle button
toggleButton.addEventListener('click', () => {
// Toggle the password input type between 'password' and 'text'
passwordInput.type = passwordInput.type === 'password' ? 'text' : 'password';
});
Comments
Please log in to leave a comment.