I use e.which jquery to run the function when ENTER is pressed, but I want this function to be called only if the special input field is focused (where the cursor is blinking).
My current jquery function.
$(document).keyup(function(e) { if (e.which == 13) { var page = $("#userpage").val(); if(page > 0) { $("#search").click(); } else { $('.save').click(); } } });
I want $ ("# search"). click (); to call, only if #search_text is focused or has some input, because I have several input fields and users usually press the enter button and press Enter. This function is called.
Thanks.
javascript jquery
Shishant
source share