當頁面加載時,使用 autofocus 屬性將光標置于文本框中。 autofocus 屬性是一個布爾屬性。如果存在,它指定 元素在頁面加載時應自動獲得焦點。這是一個示例 –
示例
<!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>
登錄后復制
以上就是當頁面加載時,如何在文本框中放置光標(自動聚焦)?的詳細內容,更多請關注www.92cms.cn其它相關文章!






