【发布时间】:2018-05-30 22:40:17
【问题描述】:
我使用 html 和 jquery 为我的密码输入实现了一个查看密码按钮,因此当我在 Microsoft Edge 和 IE 中运行它时,浏览器本身默认有一个按钮来查看 type=password 输入的密码.结果将是两个查看密码按钮!
现在我有 3 个我认为的解决方案!
1.禁用 Edge 和 IE 查看密码默认按钮(如何?)
2。在 Edge 和 IE 中禁用我的查看密码按钮(如何?)
3。为 chrome 和 Firefox 启用相同的选项(如何?)
我认为第三个解决方案是最好的。 chrome 和 Firefox 有默认的查看密码按钮吗?如果他们有我该如何使用它们?
这是我的代码:
<input type="password" class="form-control" id="password" placeholder="password " name="password">
<span class="input-group-btn">
<button id="show_password" class="btn btn-secondary" type="button" style="padding:9px;">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
</span>
<script>
$('#show_password').hover(function functionName() {
//Change the attribute to text
$('#password').attr('type', 'text');
$('.glyphicon').removeClass('glyphicon-eye-open').addClass('glyphicon-eye-close');
}, function () {
//Change the attribute back to password
$('#password').attr('type', 'password');
$('.glyphicon').removeClass('glyphicon-eye-close').addClass('glyphicon-eye-open');
}
);
</script>
【问题讨论】:
标签: html css google-chrome passwords microsoft-edge