I've asked this question because of something I need to and I'm having some problems with jQuery. So I'm opening this question 'cause others may have this too.
In the answer posted in my other question, the user Felix tells me to do something like this:
$(document).keypress(function(e) {
e.preventDefault();
if(e.which == 13 ) {
if($("#searchInput").is(":focus")) {
alert("search form submitted");
return false;
} else {
alert("save form submitted");
return false;
}
}
});
That seems to be what I need, however, the condition if($("#searchInput").is(":focus"))
is always returning True, no mather what control is focused.
Anyone has a clue why this might be happening or any other way I could do this?