<分区>
<分区>
Possible Duplicate:
Stop chrome from auto styling input type=search
我想添加许多搜索输入框用来清除信息的小“X”,但我需要保留自己的输入背景、字体大小等。有什么建议吗?
input type"search"
完全改变布局...
最佳答案
您可以尝试使用常规文本框,并在其上方移动图像,这样它就不会与背景图像混淆。
HTML
<div class="clearable">
<input type="text"/>
<img src="http://www.hanebutt.co.uk/uploads/content/close_x.gif" />
</div>
CSS
.clearable img {position: relative; left: -20px;}
jQuery
$(document).ready(function() {
$('.clearable img').click(function() {
var theInput = $(this).parent().find('input');
theInput.val("");
theInput.focus();
});
});
您可以在此处查看实际效果:http://jsbin.com/afafet
关于jquery - input type=search - 如何获取 "x"但保留我的原始输入布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11565396/