JSFiddle - React, Tailwind, and code Playground

by Lalji Tadhani

HTML

<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<div class="pwdMask">
   <input type="password" class="form-control" name="_password" placeholder="(...)" />
   <span class="focus-input"></span>
   <span class="fas pwd-toggle fa-eye-slash"></span>
</div>

JavaScript

var e = $(".pwdMask > .form-control"),
        t = $(".pwd-toggle");

$(t).on("click", function (t) {
        t.preventDefault(), 
            $(this).toggleClass("fa-eye fa-eye-slash"), 
            $(this).hasClass("fa-eye") ? $(e).attr("type", "text") : $(e).attr("type", "password")
    })