$ .focus () does not work in chrome

In the chrome developer tools console, I select the input[type="text"] element, and then try to focus on it, for example $('input#foo').focus() . It does not work, an error does not occur, but the element is not focused.

I spent half an hour trying to figure out the problem, so I'm posting this to help others who have this "problem" since I did not find an answer to SO.

+4
source share
1 answer

The reason for this is that the main part of the page does not allow you to divert attention from the dev tool window, so when you are on the console tab, the main part of the page cannot focus on it.

Very annoying, run your code in a script and it should work.

+7
source

Source: https://habr.com/ru/post/1489854/


All Articles