Bootstrap密碼啓示器,當我懸停眼睛按鈕時,會使PC掛起。即使沒有代碼來添加輸入,它也會自動添加輸入。 輸入已自動增加,它使我的bowser繼續,然後是我的整個PC。 這有什麼可能的原因和解決方案?這會導致我的電腦掛起。Bootstrap Password Revealer進入Bug
的jsfiddle:https://jsfiddle.net/aice09/76b99w4m/
//Password Revealer
$(".reveal").mousedown(function() {
$(".pwd").replaceWith($('.pwd').clone().attr('type', 'text'));
})
.mouseup(function() {
$(".pwd").replaceWith($('.pwd').clone().attr('type', 'password'));
})
.mouseout(function() {
$(".pwd").replaceWith($('.pwd').clone().attr('type', 'password'));
});
.btn-primary {
color: #0275d8;
background-image: none;
background-color: transparent;
border-color: #0275d8;
}
.btn-primary:hover {
background-color: #0275d8;
color: white;
border-color: #0275d8;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-1.12.3.min.jshttps://code.jquery.com/jquery-1.12.3.min.js"></script>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="form-group">
<label for="em_password">Password</label>
<div class="input-group">
<input id="em_password" name="em_password" type="password" class="form-control pwd" maxlength="8">
<span class="input-group-btn">
<button class="btn btn-default reveal" type="button"><i class="glyphicon glyphicon-eye-open"></i></button>
</span>
</div>
</div>
</div>
<!-- // Modal -->
你真的需要包括所有的疑問,HTML的? 95%是無關緊要的。可能的提示:「.pwd」選擇器匹配多少個元素? – nnnnnn
問題代碼已被編輯。只添加所需的部分。 – Ailyn
我添加了一個答案,可以在點擊時顯示密碼,但不確定這是您要做什麼,或者您是否希望在OP中使用事件功能。這有點不直觀,但如果是這樣,你可以在這些事件中改變'attr',不需要克隆。並針對保存密碼的唯一密碼字段,而不是所有'.pwd'的https://jsfiddle.net/76b99w4m/2/ –