javascript - jQuery Firefox handle behaviour on tab key -
i select suggestion entry in input field when press tab key (typical google behaviour). problem when press tab key, firefox sets focus on tab in application open, concern focus stays on input field. code looks like:
$("#search-input").keyup(function (event) { switch (event.keycode) { case 9: { // tab key pressed event.preventdefault(); foo(); bar(); //set focus input (dont works) $("#search-input").focus(); break; } default: baz(); } });
thanks!
[edit] solved! solution easy: firefox reacts on keydown
event needed put same behaviour in keydown event.
firefox reacts on keydown event needed put same behaviour in keydown event.
$("#search-input").keydown(function (event) { switch (event.keycode) { case 9: { // tab key pressed event.preventdefault(); foo(); bar(); //set focus input (dont works) $("#search-input").focus(); break; } default: baz(); } });
Comments
Post a Comment