小编suk*_*tup的帖子

在我的html网站的谷歌自定义搜索引擎中添加占位符到文本框

我使用以下代码添加了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)

但它不起作用.

jquery placeholder search-box google-custom-search

4
推荐指数
1
解决办法
4407
查看次数