使用 autofocus 屬性指定元素應(yīng)在 HTML 中加載頁面時(shí)自動獲得焦點(diǎn) –
示例 h2>
您可以嘗試運(yùn)行以下代碼來了解如何在 HTML 中實(shí)現(xiàn)自動對焦屬性 –
<!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>
登錄后復(fù)制
以上就是在HTML中如何指定元素在頁面加載時(shí)自動獲取焦點(diǎn)?的詳細(xì)內(nèi)容,更多請關(guān)注www.92cms.cn其它相關(guān)文章!