JSFiddle - React, Tailwind, and code Playground

HTML

<form>
    <input type="password" name="foo" />
    <input type="password" name="var" />

<input id="toggleBtn" type="button" value="Show chars">
</form>

JavaScript

$('#toggleBtn').toggle(function(){
       $('form input[type="password"]').prop('type','text');
        $('#toggleBtn').val('Hide chars')
        }, function(){
        $('form input[type="text"]').prop('type','password');
        $('#toggleBtn').val('Show chars')
    
    });