Показать скрыть пароль работает в Chrome, но не в Firefox - PullRequest
0 голосов
/ 05 июля 2019

Я новичок в jquery.Этот скрипт прекрасно работает в Chrome.Но когда открывается в Firefox, он не работает вообще.Кто-нибудь может мне помочь.Извините за мой плохой английский.И это мой первый вопрос.

Это мой HTML и CSS:

<div class="form-group" id="show_hide_password">
  <input class="form-control" type="password" name="password" placeholder="PASSWORD" maxlength="15" autocomplete="off">
  <a href="#"><i class="fa fa-eye-slash" style="float: right; margin-top: -29px; margin-right: 10px; color: #fff;"></i></a>
</div>

Это мой скрипт jquery:

$(document).ready(function() {
  $("#show_hide_password a").on('click', function(event) {
    event.preventDefault();
    if($('#show_hide_password input').attr("type") == "text"){
      $('#show_hide_password input').attr('type', 'password');
      $('#show_hide_password i').addClass( "fa-eye-slash" );
      $('#show_hide_password i').removeClass( "fa-eye" );
    }else if($('#show_hide_password input').attr("type") == "password"){
      $('#show_hide_password input').attr('type', 'text');
      $('#show_hide_password i').removeClass( "fa-eye-slash" );
      $('#show_hide_password i').addClass( "fa-eye" );
    }
  });
});
...