How to force autofocus on a Textbox with javascript if autofocus does not work ( autofocus is not working)



Question:  autofocus is not working on a textbox, I tried $('#textboxName').focus(); and it does not work.

Answer: If autofocus is working on your textbox, use setTimerout function to trigger autofocus on a textbox. See the code below:

$(document).ready(function(){

setTimeout(function () {
            $('#IdOfTextBox').focus();
        });
});
JavaScript autofocus not working jQuery autofocus Technology published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue


© 2021 - ErnesTech - Privacy