HTML 5 <button> autofocus 屬性
實(shí)例
當(dāng)頁面加載時(shí),會獲得焦點(diǎn)的一個(gè)按鈕:
<button type="button" autofocus="autofocus">
點(diǎn)擊這里
</button>
定義和用法
autofocus 屬性規(guī)定當(dāng)頁面加載時(shí)按鈕應(yīng)當(dāng)自動地獲得焦點(diǎn)。
如果使用該屬性,則按鈕會獲得焦點(diǎn)。
HTML 4.01 與 HTML 5 之間的差異
autoplay 屬性是 HTML 5 中的新屬性。
語法
<button autofocus="autofocus">