html:
<input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索课程/专栏/微课主页" autocomplete="on">
js:
$(".weui-search-bar__input").on('keypress', function(e) {
var keycode = e.keyCode;
//获取搜索框的值
var searchContent = $(this).val();
if (keycode == '13') {
e.preventDefault();
//请求搜索接口
if (searchContent == '') {
$.toptip('请输入搜索关键字', 'error');
} else {
searchInput();
}
}
});