Unable to set focus and cursor to input text using javascript in Chrome Console Unable to set focus and cursor to input text using javascript in Chrome Console google-chrome google-chrome

Unable to set focus and cursor to input text using javascript in Chrome Console


I think this is not related to issue with class, id, javascript or jQuery. It's the way browser console works. The console gets focus after each command is run. So the focus will not work for other inputs from the console.

To test it, run this code in console.

setTimeout(function(){$(".input.input-search").focus()},5000);

After executing it immediately click anywhere on the page to take focus out of console. Now after 5 seconds, the focus will set on input.