Default html form focus without JavaScript

后端 未结 5 2164
傲寒
傲寒 2020-12-01 03:48

Is it possible to set the default input focus on an HTML form without using JavaScript, for example:


  
Input 1:
5条回答
  •  一生所求
    2020-12-01 04:30

    You can do it in HTML5, but otherwise, you must use JavaScript.

    HTML5 allows you to add autofocus to your form element, eg:

    
    

    This does work in browsers which support HTML5 (Or rather, browsers which support this particular part of HTML5) but as you know, not everybody can use it yet.

提交回复
热议问题