Help with focus in jquery
I have two button on my confirmation popup (popup_ok & popup_cancel), I want to restrict focus on either of the two buttons untill user decides what he/she wants to do. Uptill now im doing the following
$("#popup_cance开发者_如何学Gol").blur(function() {
$("#popup_ok").focus();
$("#popup_ok").focus();
});
but this is not working, kindly guide me to better approach
Thanks in advance.
I assume it's not practical to perform a focus()
inside a blur()
event, but if you insist, I advice you to use a small timeout to force the focus to execute outside of the event bubble:
setTimeout(function() { $("#popup_ok").focus(); }, 10)
(Updated based on Matt's comment to prevent using eval()
)
精彩评论