How to replace google custom search engine's magnifying glass with a button that says “search”?

随声附和 提交于 2019-12-04 14:58:05
function myCallback() {
    $("td.gsc-search-button input").attr("type", "submit").attr("value", "submit");
}

window.__gcse = {
    callback: myCallback
}; //.......load google CSE tag after this

This works for me and it keeps all of the event handlers in place.

Using jQuery, you can do it quite easily.

After the Google snippet has loaded, execute this code:

$("td.gsc-search-button").empty().html('<input type="button" value="search" title="search">');

You just need to make sure that the code above runs after Google's code.

-Asrar

The only way that I found to add the search button with text instead of image is changing the theme.

You can change the theme by clicking on the "Look and feel" link on the left side menu during the creation process. Then click on the theme tab to change it. Once you changed to a theme that has the search text you can click on the "Customize" tab to change the colours even more.

https://support.google.com/customsearch/answer/4513783?hl=en

The CSS attribute which is not allowing the button image to be shown is the global box-sizing: inherit in the bootstrap.css file. If you're using bootstrap, you should override this attribute to have inherit or content-box values. You can override this attribute by putting your custom search elements in a div and giving that div a class which has this attribute with !important.

I just found that out and it works for me.

That is it!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!