Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.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
Javascript 第一次单击时未显示文本框_Javascript_Jquery - Fatal编程技术网

Javascript 第一次单击时未显示文本框

Javascript 第一次单击时未显示文本框,javascript,jquery,Javascript,Jquery,我有一个在点击搜索按钮时显示的输入文本框,但在第一次点击时不显示,在第一次点击或双击后显示。如何解决这个问题 我的代码: 搜索 X 点击 $'loaction-search'。单击函数{ $locationsearchbox.animate{ 宽度:“切换” },350,功能{ $this.focus }; } $document.on'click',function e{ var$target=$e.target; 如果!$target.closest'.clear search'.leng

我有一个在点击搜索按钮时显示的输入文本框,但在第一次点击时不显示,在第一次点击或双击后显示。如何解决这个问题

我的代码:

搜索 X 点击 $'loaction-search'。单击函数{ $locationsearchbox.animate{ 宽度:“切换” },350,功能{ $this.focus }; } $document.on'click',function e{ var$target=$e.target; 如果!$target.closest'.clear search'.length&&!$target.closest'locationsearchbox.length{ $'locationsearchbox'。隐藏; } }; $.clear-search.clickfunction{ $'locationsearchbox'.val; } 使用先显示后聚焦

搜索 X 点击 $'loaction-search'。单击函数{ $locationsearchbox.animate{ 宽度:“切换” },350,功能{ $ $this.show; $this.focus; }; } $document.on'click',function e{ var$target=$e.target; 如果!$target.closest'.clear search'.length&&!$target.closest'locationsearchbox.length{ $'locationsearchbox'。隐藏; } }; $.clear-search.clickfunction{ $'locationsearchbox'.val; } 使用先显示后聚焦

搜索 X 点击 $'loaction-search'。单击函数{ $locationsearchbox.animate{ 宽度:“切换” },350,功能{ $ $this.show; $this.focus; }; } $document.on'click',function e{ var$target=$e.target; 如果!$target.closest'.clear search'.length&&!$target.closest'locationsearchbox.length{ $'locationsearchbox'。隐藏; } }; $.clear-search.clickfunction{ $'locationsearchbox'.val; }
tghe代码的主要问题是您为隐藏locationsearchbox而处理的逻辑错误。您还必须排除loaction搜索元素,因为我们已经在处理相同的click事件,否则该操作将触发两次

$loaction-search.clickfunction{ $locationsearchbox.animate { 宽度:切换, }, 350, 作用{ $this.focus; } ; }; $document.onclick,函数e{ var$target=$e.target; 如果 !$target.closest.clear-search.length&& !$target.closestlocationsearchbox.length&& !$target.closestloaction-search.length { $locationsearchbox.hide; } }; $.clear-search.clickfunction{ $locationsearchbox.val; }; 搜索 X 点击
tghe代码的主要问题是您为隐藏locationsearchbox而处理的逻辑错误。您还必须排除loaction搜索元素,因为我们已经在处理相同的click事件,否则该操作将触发两次

$loaction-search.clickfunction{ $locationsearchbox.animate { 宽度:切换, }, 350, 作用{ $this.focus; } ; }; $document.onclick,函数e{ var$target=$e.target; 如果 !$target.closest.clear-search.length&& !$target.closestlocationsearchbox.length&& !$target.closestloaction-search.length { $locationsearchbox.hide; } }; $.clear-search.clickfunction{ $locationsearchbox.val; }; 搜索 X 点击
这仅适用于第一次尝试多次单击搜索按钮。您可以看到问题此功能仅适用于第一次尝试多次单击搜索按钮。你可以看到这个问题