1 if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) { 2 $(window).load(function () { 3 $('input:-webkit-autofill').each(function () { 4 var text = $(this).val(); var name = $(this).attr('name'); 5 $(this).after(this.outerHTML).remove(); 6 $('input[name=' + name + ']').val(text); 7 }); 8 }); 9 }
自動填充原理,找到input標簽type類型為password的對象,識別該對象為密碼框,查找密碼框上面的第一個type為text的input對象為登錄名框。