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.

Continue Reading:

Dark Mode Toggle

Published on January 26, 2024

javascript

JavaScript Add Animation to HTML Element

Published on January 26, 2024

javascript

JavaScript Code Snippet: Fetch and Display Data from an API

Published on August 04, 2024

javascriptjson

Managing Modals with Livewire and JavaScript

Published on August 14, 2024

javascriptphp

Easy JavaScript Tutorial for Beginners

Published on September 18, 2024

javascript

Exporting Table Row Data to CSV in JavaScript

Published on October 24, 2024

php