setTimeout(function () {
$('#pass').focus();//用以解决firefox不主动触发focus之前自动填充密码不触发focus事件的问题。
$('.reg-text').each(function () {
if ($(this).val().trim() == '') {
$(this).parent().removeClass("reg-input-focus");
} else {
$(this).parent().addClass("reg-input-focus");
}
});
if (window.navigator.userAgent.indexOf('Chrome') > -1) {//chrome自动填充密码后,获取密码框val值为空字符串,只好通过当前input框是否有:-webkit-autofill来判断当前是否已经填充了密码。。
if ($('input:-webkit-autofill').length===2) {
$('#pass').parent().addClass("reg-input-focus")
}
}
$('#name').focus();
}, 300);
$('.reg-text').focus(function () {
$(this).parent(".reg-input").addClass("reg-input-focus");
$(this).change(function () {
if ($(this).val().trim() == '') {
$(this).parent().removeClass("reg-input-focus");
} else {
$(this).parent().addClass("reg-input-focus");
}
});
}).blur(function () {
if ($(this).val().trim() == '') {
$(this).parent().removeClass("reg-input-focus");
} else {
$(this).parent().addClass("reg-input-focus");
}
});
在火狐和chrome不同的自动填充密码机制下实现根据密码框是否有内容来添加不同类的功能
猜你喜欢
转载自blog.csdn.net/goodgirl1991/article/details/72963638
今日推荐
周排行