Focus removed even after event returns false (cancelled event)
I have implemented hotkeys using jquery.hotkeys
$("textarea").bind("keydown", "tab", function() {
alert("tab");
return false;
});
But I noticed that after the function returns, the focus is not in t开发者_开发技巧he textbox anymore. Its not in the next control too. I could do this.focus(), but I wonder why after returning false, the focus will be gone? also I am curious where did the focus go to
http://jsfiddle.net/Tu6vF/1/
It's not the return
, it's the alert()
that loses focus (that's also the answer for the "where did it go?" part...the alert window it created).
Here's your code without the alerts, never losing focus (at least, not because of your binds, clicking outside, etc works normally).
精彩评论