【问题标题】:How to move the 'clear results' button to the results in Google's CSE?如何将“清除结果”按钮移至 Google CSE 中的结果?
【发布时间】:2015-09-13 20:24:55
【问题描述】:

如何将清除结果按钮移动到结果部分? I found this answer 但它适用于不同或更旧的搜索版本,我似乎无法在此版本的自定义搜索中使用相同的概念。

这是我的代码:

<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script>
google.load('search', '1', {language: 'en'});
google.setOnLoadCallback(function() {
    var customSearchOptions = {};
    var customSearchControl =   new google.search.CustomSearchControl('{param_id}', customSearchOptions);
    var options = new google.search.DrawOptions();
    options.setAutoComplete(true);
    customSearchControl.draw('cse', options);
    jQuery('input.gsc-input').val('Search');
}, true);
</script>

我已尝试使用此jQuery('td.gsc-clear-button').insertAfter(jQuery('.gsc-above-wrapper-area')); 尝试将清除按钮移至搜索结果,但没有任何反应。

我可以使用 jQuery('input.gsc-input').val('Search'); 添加占位符文本,但更改清除按钮显然没有那么简单。

我也会在 Google 的帮助论坛上问这个问题,看看那里是否有人有答案。如果有,我一定会在此处添加。

【问题讨论】:

  • 您需要这方面的帮助吗?

标签: javascript jquery google-custom-search


【解决方案1】:

获取清除结果按钮:

var $grabClearResults = $('.gsib_b');

然后将按钮放入结果中:

jQuery('.gsc-result-info-container').after($grabClearResults);

【讨论】:

    猜你喜欢
    • 2017-03-09
    • 2011-06-07
    • 1970-01-01
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多