When the page loads, use the autofocus attribute to place the cursor in the text box. autofocus The property is a Boolean property. If present, it specifies that the element should automatically receive focus when the page loads. Here is an example -
<!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>
The above is the detailed content of How can I position the cursor (auto focus) in a text box when the page loads?. For more information, please follow other related articles on the PHP Chinese website!