如何在我的Google自定义搜索框中添加占位符?

问题描述 投票:0回答:1

我尝试了在这里找到的其他代码,但是没有用。

这是我的搜索框常规代码:

<script async="" src="https://cse.google.com/cse.js?cx=008573911755377469615:xhdlwjbvh7o"></script>
javascript
1个回答
0
投票

仅在加载窗口时设置属性。

window.onload = myCustomPlaceholder;

function myCustomPlaceholder() {
    document.getElementById("gsc-i-id1").setAttribute("placeholder", "my custom search placeholder")
}
© www.soinside.com 2019 - 2024. All rights reserved.