在文本框按回车键搜索

<form method="post" action="/index.php?controller=blog&action=stage" >
	<input type="text" name="search" id="search"  placeholder="Search blog"><button type="submit" id="searchbutton">Search</button>
</form>

js:

$('#search').bind('keypress', function (event) { 
if (event.keyCode == "13") { 
$("#searchbutton").click();
}
})

猜你喜欢

转载自blog.csdn.net/weixin_41728561/article/details/80966740