我试图让这个在我的网站上为我工作,但这是不可能的..我想我做错了什么..
我从 BenjaminMiles 的网站上发布了这个 jquery 代码:
<script>
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).load(function(){
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="text" name="text" />
但仍然不起作用...还尝试了盒子阴影技巧,但对我不起作用,因为我使用的是带有背景图像的输入。
我的 body 标记中有上面的代码,所以..我做错了什么?
最佳答案
您可能不需要 jQuery。使用 transition
使黄色背景消失。您所要做的就是如下:
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
transition: background-color 5000s ease-in-out 0s;
}
要更改文本颜色,请添加
-webkit-text-fill-color: white !important;
将白色
替换为您选择的颜色。
关于javascript - 使用此 jquery 更改 chrome 自动填充黄色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28929817/