<form action="#" method="post">
<input id="search" name="" value="" type="search" placeholder="请输入您想要搜索的问题" >
<input id="search" name="" value="" type="search" placeholder="请输入您想要搜索的问题" >
</form>
$("#search").on('keyup', function(e) {
var keycode = e.keyCode;
//获取搜索框的值
var searchContent = $(this).val();
var k_url = document.domain;
if (keycode == '13') {
e.preventDefault();
//请求搜索接口
if (searchContent == '') {
alert('请输入检索内容!');
} else {
alert(searchContent);
}
}
});