我使用以下代码添加了Google自定义搜索引擎.
(function() {
var cx = '005899633628958982661:wekn1lpckzg';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
Run Code Online (Sandbox Code Playgroud)
现在我的网站有一个可用的搜索框,唯一的问题是我无法在搜索文本框中使用占位符.
我也尝试过代码
$('input.gsc-input').attr('placeholder', 'custom text here');
Run Code Online (Sandbox Code Playgroud)
但它不起作用.