如何指定元素應該在頁面載入時在 HTML 中自動獲得焦點?
使用 autofocus 屬性來指定元素在 HTML 中的頁面載入後應自動獲得焦點 −
示例
你可以嘗試執行以下程式碼來了解如何在 HTML 中實現 autofocus 屬性 −
<!DOCTYPE html>
<html>
<body>
<p>Click on the below button to generate an alert box.</p>
<button type = "button" autofocus onclick = "alert('Welcome!')">Result</button>
</body>
</html>
廣告
資料結構
計算機網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP