1. 程式人生 > >【前端】在文字框按回車鍵搜尋

【前端】在文字框按回車鍵搜尋

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