Advertisement
afsarwebdev

password show & hide eye icon close & open

Sep 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. //Live https://codepen.io/Sohail05/pen/yOpeBm
  2. //HTML
  3. <div class="ic-single-input">
  4. <input id="password-field" type="password" placeholder="password">
  5. <span toggle="#password-field" class="fa fa-fw fa-eye field-icon toggle-password"></span>
  6. </div>
  7. // css
  8. .ic-single-input {
  9. position: relative;
  10. }
  11. .ic-single-input .toggle-password {
  12. position: absolute;
  13. right: 10px;
  14. top: 17px;
  15. font-size: 20px;
  16. }
  17. //JS
  18. $(".toggle-password").click(function() {
  19. $(this).toggleClass("fa-eye fa-eye-slash");
  20. var input = $($(this).attr("toggle"));
  21. if (input.attr("type") == "password") {
  22. input.attr("type", "text");
  23. } else {
  24. input.attr("type", "password");
  25. }
  26. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement