How can I make jquery .focus()
to work without setting tabindex of a div
$("#msgdiv").focus();
<div id="msgdiv" tabindex="100"> </div>
what is the best practise for this
what i want to achieve: After changing the password i want to display the acknowledgment message that the password has been changed and put focus on that div.
Simply, you can't do focus on a div without tabindex, see documentation.
Don't really know what you wanna achieve with this code-snippet, but if you wanna trigger a focus event, you should use trigger:
$("#msgdiv").trigger('focus');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With