How to set focus to an input element when it enters the DOM?
input
When a button is clicked the input element is displayed. How to set the focu
Assuming you only need one visible input on the page at a time to have autofocus Poh Zi How's suggestion of using the autofocus is probably the simplest.
autofocus
should do the trick, no JS needed!