【发布时间】:2018-06-23 14:26:47
【问题描述】:
如何将搜索按钮添加到HTML?我已经尝试添加它,但是当我搜索示例YouTube 时显示结果但不显示我的搜索文本YouTube 我该如何解决这个问题,我需要在此代码中更改什么?谢谢
.main{
position: absolute;
top: 10px;
left: 25%;
width: 50%;
height: auto;
text-align: center;
}
.q{
padding: 5px;
width: 90%;
margin-top: -30px;
border: solid 1px #c68e00;
font-size: 17px;
font-family: Arial;
height: 40px;
}
<script>
(function() {
var cx = '004533415228465222070:r2ak9s12hwi';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchresults-only></gcse:searchresults-only>
</div>
<div class="main">
<br/><br/>
<form action="" method="GET">
<input class="q" name="q" placeholder="Search by Name or type URL" title="Search ..." value="" />
</form>
【问题讨论】:
标签: javascript jquery html search google-search-api