使用 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>
登录后复制
以上就是在HTML中如何指定元素在页面加载时自动获取焦点?的详细内容,更多请关注www.92cms.cn其它相关文章!






