首先建立div,在div内建立两个input框,一个是输入搜索框,另一个放入搜索图片
描述:οnkeydοwn=“if(event.keyCode==13){gosubmit();}” 方法就是按回车键进行搜索的方法
<div class="div_input">
<input class="xxgk_input" onkeydown="if(event.keyCode==13){gosubmit();}" id="submit"/>
<input type="button" class="input_button" onclick="gosubmit()"/>
</div>
.div_input{
display:inline-block;
position: relative;
width: 510px;
height: 50px;
vertical-align: middle;
}
.xxgk_input{
text-indent: 10px;
font-size: 18px;
height: 48px;
width: 510px;
margin: 0 auto;
border-radius: 9px;
outline: none;
border: 1px solid rgb(45,102,165);
}
.input_button{
position: relative;
right: -223px;
top: -47px;
width: 40px;
height: 40px;
background: none;
background-image: url(../img/ss.png);
border: none;
background-repeat: no-repeat;
vertical-align: middle;
outline: none;
cursor: pointer;
}
![用于搜索的图片](https://img-blog.csdnimg.cn/20191206102017549.png)
## 搜索的js方法
```css
/*按回车键进行搜索*/
function gosubmit(){
var submit=document.getElementById("submit").value;
console.log(submit);
}