Advertisement
Vladimir3261

Untitled

Apr 20th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.86 KB | None | 0 0
  1. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  2. <input type="password" id="pass" />
  3. <button id="show-pass" class="" data-password="pass" data-showclass="show" data-hideclass="hide">SHOW</button>
  4.  
  5. <script>
  6.    $(document).ready(function () {
  7.        $("#show-pass").click(function () {
  8.            var passwordInput = $("#"+$(this).data('password'));
  9.            if( passwordInput.attr('type') === 'password' ){
  10.                passwordInput.attr('type', 'text');
  11.                $(this).removeClass($(this).data('hideclass'));
  12.                $(this).addClass($(this).data('showclass'));
  13.            }else{
  14.                passwordInput.attr('type', 'password');
  15.                $(this).removeClass($(this).data('showclass'));
  16.                $(this).addClass($(this).data('hideclass'));
  17.            }
  18.        });
  19.    });
  20. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement