How do I make a field autofocus?
问题 I need this field to be focused when the user opens the page. I don't know if it changes anything but it's inside a modal window I load from a PHP file. Is there an easy way to do it? 回答1: JavaScript autofocusers (as given in the other answers here) will work but can be annoying for some users. For example, if you focus a different field while a page is still loading, the JavaScript may "help" you by moving the focus and making you type in the wrong field. This question on ux.stackexchange