移动端 input 输入框使软键盘回车键变为搜索按钮
HTML iOS About 473 words设置 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"
}
});
Views: 5,416 · Posted: 2019-06-15
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...