JSFiddle - React, Tailwind, and code Playground
HTML
<input type="password" id="new_pass" value="" placeholder="New Password">
<label class="pw_show">
<input type="checkbox">Show Password
</label>
JavaScript
var pwi = $('#new_pass');
$('.pw_show').on('mousedown', function () {
$('.pw_show input').prop('checked', true);
pwi.prop('type', 'text');
});
$('.pw_show').on('mouseup', function () {
pwi.prop('type', 'password');
setTimeout(function() {
$('.pw_show input').prop('checked', false);
}, 50);
});