[英]Clear query term displaying in search bar when results page loads
On a search results page, I have: 1) a global search bar in the site header 2) another search bar, specific to the page, that's part of a custom image search. 在搜索结果页面上,我具有: 1)网站标题中的全局搜索栏2)特定于页面的另一个搜索栏,这是自定义图像搜索的一部分。
Issue: When I perform a search using #2, and the results page loads, BOTH search input fields are populated with my search term. 问题:当我使用#2执行搜索并加载结果页面时,两个搜索输入字段都填充了我的搜索字词。
Desired functionality: a) both fields should be cleared when the results page loads OR, at the very least: b) a #2 search term shouldn't be populated in the #1 search field as well 所需功能: a)结果页面加载时,两个字段都应清除,或者至少:b)#1搜索字段中也不应填充#2搜索词
There is some existing script tied to the site search, but I'd like to use a separate solution, ideally with jQuery, to clear the search fields. 有一些与网站搜索相关的现有脚本,但是我想使用一个单独的解决方案,最好是与jQuery一起使用,以清除搜索字段。 This way the user doesn't have to manually clear out text when performing a new search.
这样,用户在执行新搜索时不必手动清除文本。 Any ideas?
有任何想法吗?
here is a working fiddle: 这是一个工作的小提琴:
http://jsfiddle.net/acturbo/S3tqZ/ http://jsfiddle.net/acturbo/S3tqZ/
html: 的HTML:
<div id="search-bar">
<form id="search-bar-form">
<input id="search-bar-input"> value to find
<a href="#" id="search-barbtn">Search</a>
</form>
</div>
<div id="search-bar-page">
<form id="search-bar-page-form">
<input id="search-bar-page-input"> value to find on page
<a href="#" id="search-bar-page-btn">Search</a>
</form>
</div>
jquery: jQuery的:
$().ready(function() {
$("#search-bar-page-btn").on("click", function(){
$("#search-bar-input").val("");
$("#search-bar-page-input").val("");
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.