移动端 input 输入框使软键盘回车键变为搜索按钮
HTML iOS 大约 473 字设置 type=search
注意:iOS
必须添加form
且添加action
<form action="#" onsubmit="return false">
<input class="search-input" placeholder="请输入关键字..." type="search" results="10">
<button type="button" class="search-button">搜索</button>
</form>
监听回车事件
使用jQuery
方式
$('.search-button').click(function () {
let keyword = $('.search-input').val().trim();
if (keyword.length > 0) {
window.location.href = "/search/"+keyword+".html"
}
});
阅读 3970 · 发布于 2019-06-15
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
走进 Rust:流程控制阅读 1742
-
Vue $nextTick 解决 v-if 切换后操作 DOM 报错问题阅读 116
-
IDEA 使用 Kubernetes 瑞士军刀 Telepresence 进行网络代理阅读 310
-
微信小程序基于 Parser 添加长按复制、代码高亮等功能阅读 3867
-
走进 Rust:迭代器阅读 1433
-
软考-系统架构设计师:系统运行与维护阅读 1653
-
npm 查看版本信息阅读 1099
-
Android 有权查看使用权限的应用阅读 5474
-
Java 并发编程之线程池大小阅读 935
-
MySQL Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root阅读 3250