在頁面載入 HTML 時如何將游標(自動對焦)置於文字框中?
使用 autofocus 屬性,可以在頁面載入時將游標置於文字框中。autofocus 屬性是一個布林屬性。如果存在,則指定 <input> 元素在頁面載入時應自動獲得焦點。示例如下:-
示例
<!DOCTYPE html> <html> <body> <form action = "/new.php"> Name: <input type = "text" name = "name" autofocus><br> Subject: <input type = "text" name = "sub"><br> <input type = "submit"> </form> </body> </html>
廣告