I have this very simple form:
<form id="header_search"><input type="text" value="search"></form>
and this is my jQuery:
$("#header_search").keypress(function(e)
{
e.preventDefault();
alert("searching :)");
return false;
});
But this function doesn’t get triggered on submit by pressing enter. Any idea what is going wrong?
Thanks!!
There is no
keypressevent onform, usesubmitwhich will work with bothenterandsubmitbuttonclick.Demo: http://jsfiddle.net/usmanhalalit/7f6y8/