通过form实现enter事件

结构

<form action=‘#’>

<input type='search' />

<button>搜索</button>

</form>

在这种情况下即使给button加上事件,按enter键也会执行点击事件中的代码(pc-移动web皆可以)。(action需为javascript:; 并且默认的提价方式是get)

posted @ 2018-02-09 10:50  闲鱼一只  阅读(207)  评论(0编辑  收藏  举报