jQuery call function if Enter hit
jquery
Solution
Trigger the click handler explicitly:
$("#s").keypress(function(e) {
if(e.which == 13) {
alert('You pressed enter!');
$("#go").click();
}
});
Problem
I am calling a function on button click code is given blow: ``` <input type="button" value="Search" id="go" /> $("#go").click(function () { ... }); ``` now I catch if user hit enter key from keyboard by this function: ``` $("#s").keypress(function(e) { if(e.which == 13) { alert('You pressed enter!'); } }); ``` but how could I call ``` $("#go").click(function () { ... }); ``` both if user hits enter key & on click GO button?