
使用 autofocus 属性指定元素应在 HTML 中加载页面时自动获得焦点 -
示例 h2>
您可以尝试运行以下代码来了解如何在 HTML 中实现自动对焦属性 -
<!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>











