在沒有 HTML 中 JavaScript 情況下,當頁面載入時,如何將自動對焦放置在文字框中?


autofocus 屬性是布林屬性。存在時,它指定 <input> 元素在頁面載入時應自動獲得焦點。下面給出了一個示例

<!DOCTYPE html>
<html>
   <body>
      <form action = "/new.php">
         First Name: <input type = "text" name = "fname" autofocus><br>
         Last Name: <input type = "text" name = "lname"><br>
         <input type="submit">
      </form>
   </body>
</html>

更新於:2020 年 6 月 4 日

135 次瀏覽

開啟你的職業生涯

完成課程獲取認證

開始使用
廣告
© . All rights reserved.