1. 程式人生 > >進到頁面後input輸入框自動獲取焦點

進到頁面後input輸入框自動獲取焦點

只要在該input標籤後新增autofocus="autofocus"即可

程式碼例項:

<html>
    <head></head>
    <body>
        使用者名稱:<input type="text" id="username" name="username" autofocus="autofocus"/><br/>
        密碼:<input type="text" id="password" name="password"/><br/>
        <input type="submit" name="submitBtn" value="提交"/>
    </body>
</html>