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;
}

amao
34 声望3 粉丝

不学无术的大三狗一只