Removing input background colour for Chrome autocomplete?

前端 未结 30 1862
失恋的感觉
失恋的感觉 2020-11-22 04:02

On a form I\'m working on, Chrome is auto-filling the email and password fields. This is fine, however, Chrome changes the background colour to a pale yellow colour.

30条回答
  •  囚心锁ツ
    2020-11-22 04:35

    I've got a solution if you want to prevent the autofill from google chrome but its a little bit "machete" , just remove the class that google chrome adds to those inputs fields and set the value to "" if you dont need to show store data after load.

    $(document).ready(function () {
        setTimeout(function () {
                var data = $("input:-webkit-autofill");
                data.each(function (i,obj) {
                $(obj).removeClass("input:-webkit-autofill");
                        obj.value = "";
                });
        },1);           
    });
    

提交回复
热议问题