I have a page like AJAX-y. When the user presses "GO", I need to execute a specific javascript function. I also want to simulate a “GO” click when the user presses “Enter” or “Return”. Please note that I do not want to “submit” the page. The reason is because I am doing everything with JavaScript.
To process the "Enter" / "Return" key, click in IE and FireFox, I use the following code:
$(document).ready(function () {
$('#root').keypress(function(e) {
if (e.keyCode == '13') {
goButton();
}
});
});
Unfortunately, this code does not work in Chrome. The goButton () function is called. The problem is that the page is being sent. What am I doing wrong?
source
share