Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

JavaScript: Show password icon

$
0
0

I have this HTML...

<div class="signin-form-label-group">
        <input type="password" id="password" name="password" class="form-control"
               placeholder="Password"
               required>
        <label for="password">Password</label>
        <span toggle="#password" class="mdi mdi-eye-off toggle-password"></span>
      </div>

And this JavaScript...

$(".toggle-password").click(function() {
      $(this).toggleClass("mdi mdi-eye");
      var input = $($(this).attr("toggle"));
      input.type === "password" ? input.type = "text" : input.type = "password";
    });

I am using material design icons. Problem is that when clicking the eye-off icon, the text is displayed but the icon does not change to eye only. Any way to fix it?


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>