jQuery focus not working in Chrome

Sometimes before I faced a issue the jQuery focus not working in Chrome and in Mozilla It was working fine. I have google the issue and came up with  a solution. Same solution I am explaining here so that It can be useful for developers.


I have an input box and after submitting the data input in this element and trying to focus on it eg

It doesn’t work, no error is thrown but the element isn’t focused. 

It seems bug in chrome. Sometimes it is too fast to execute events properly. So I have got the solution of this issue by doing some delay using setTimeout() as follows :

and this code works fine, using setTimeout() with a minimal delay. It will slow down Chrome and make it work.

I hope this article would be helpful and if you have any problem facing in respect of jQuery or JavaScript, you can write us on our site http://fellowtuts.com. We will try our best to provide you a solution as soon as possible.

You Might Interested In