移动端使用JQ监听键盘事件,回车搜索
1.输入框类型设置为 search
<input type="search" class="mobile-search-input" placeholder="搜索一下">
2.监听键盘事件
$(".mobile-search-input").on('keypress', function (e) {
if (e.keyCode == '13') { //按下回车
e.preventDefault();
/*********/
}
});
3.去除搜索框里的清空按钮
.mobile-search-input::-webkit-search-cancel-button {
display: none;
}
阅读 2.5k
0 条评论
得票最新