源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> <style> input:focus { background-color:yellow; } </style> </head> <body> <form action="demo-form.asp" method="get"> First name: <input type="text" name="fname" /><br> Last name: <input type="text" name="lname" /><br> <input type="submit" value="提交" /> </form> <p><b>注意:</b>僅當 !DOCTYPE 已經聲明時 IE8 支持 :focus.</p> </body> </html>
運行結果