在没有 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.