Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <input type="password" id="pass" />
- <button id="show-pass" class="" data-password="pass" data-showclass="show" data-hideclass="hide">SHOW</button>
- <script>
- $(document).ready(function () {
- $("#show-pass").click(function () {
- var passwordInput = $("#"+$(this).data('password'));
- if( passwordInput.attr('type') === 'password' ){
- passwordInput.attr('type', 'text');
- $(this).removeClass($(this).data('hideclass'));
- $(this).addClass($(this).data('showclass'));
- }else{
- passwordInput.attr('type', 'password');
- $(this).removeClass($(this).data('showclass'));
- $(this).addClass($(this).data('hideclass'));
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement