Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 输入类型=搜索-如何获取;x";但保留我原来的输入布局_Jquery_Html_Css - Fatal编程技术网

Jquery 输入类型=搜索-如何获取;x";但保留我原来的输入布局

Jquery 输入类型=搜索-如何获取;x";但保留我原来的输入布局,jquery,html,css,Jquery,Html,Css,可能重复: 我想添加许多搜索输入框用来清除信息的小“X”,但我需要保留自己的输入背景、字体大小等。有什么建议吗 input type"search" 完全更改布局…您可以尝试使用一个常规文本框,其中的图像已移动到其顶部,这样它就不会与背景图像混淆 HTML jQuery $(document).ready(function() { $('.clearable img').click(function() { var theInput = $(this).parent().find

可能重复:

我想添加许多搜索输入框用来清除信息的小“X”,但我需要保留自己的输入背景、字体大小等。有什么建议吗

input type"search"

完全更改布局…

您可以尝试使用一个常规文本框,其中的图像已移动到其顶部,这样它就不会与背景图像混淆

HTML

jQuery

$(document).ready(function() {
  $('.clearable img').click(function() {
    var theInput = $(this).parent().find('input');
    theInput.val("");
    theInput.focus();
  });
});
你可以在这里看到它的作用:

 .clearable img {position: relative; left: -20px;}
$(document).ready(function() {
  $('.clearable img').click(function() {
    var theInput = $(this).parent().find('input');
    theInput.val("");
    theInput.focus();
  });
});