Posts Learn Components Snippets Categories Tags Tools new About
/

How to View Toggle Password On and Off using jQuery

Learn how to toggle password field on and off using jQuery the easy way

Created on Nov 07, 2021

12 views

To toggle the view password field on and off you can simply make use of jQuery "mouseup" and "musedown" event. The way to view the password value is simply by changing the input field type from "password" to "text". Do check the code implementation below for the full code example.
$("#password-show-button").mouseup(function () {
    $("#password").attr("type", "password");
});

$("#password-show-button").mousedown(function () {
    $("#password").attr("type", "text");
});

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)