杰拉斯的博客

标签:Bug

jQuery Bug:获取不到Chrome自动填充表单的值

杰拉斯 杰拉斯 | 时间:2013-03-03, Sun | 14,040 views
前端开发 
// Stop chrome's autocomplete from making your input fields that nasty yellow. Yuck.
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);
		});
	});
}