How can I focus an HTML5 <button> element (preferrably with jQuery)?
I have tried:
$('#myButton').focus();
and
$('#myButton').trigger('focus');
I tried it with and without a tabstop on the button, and no luck so far.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Figured it out. I was trying to focus the button from within another event handler (which apparently doesn’t work).
My solution was to add a simple 1ms timeout:
This makes it work perfectly.