[英]How do I reset input autocomplete styles?
I have a simple Bootstrap form that is proceeded via JavaScript. 我有一个简单的Bootstrap表单,通过JavaScript进行。 Once the submit button is clicked, it proceeds its data and resets the input values without reloading the page: 单击提交按钮后,它将继续其数据并重置输入值,而无需重新加载页面:
if( json.success ) {
$('#form_sendemail').find('.form-control').val('');
}
The problem is that if there were any autocompleted form fields (highlighted with yellow in Chrome), they stay highlighted even after the form has been sent and the form fields cleared. 问题是,如果有任何自动填充的表单字段(在Chrome中以黄色突出显示),即使在表单已发送并且表单字段已清除后,它们仍会保持突出显示。 How do I reset those styles without reloading the page? 如何在不重新加载页面的情况下重置这些样式? (setting background-color
to !important
didn't help). (将background-color
设置为!important
没有帮助)。
You can try this 你可以试试这个
For Chrome 适用于Chrome
input:-webkit-autofill {
background-color: #FAFFBD !important;
color: #2a2a2a !important;
}
Script 脚本
$("input[type='text']").bind('focus', function() {
$(this).css('background-color', '#fff');
$(this).css('color', '#000');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.