How would I do the following in javascript:
<textarea onload="focus">Here is some text</textarea>
Basically, I want the textarea field to be focused on, and I want to do it within the html tag.
Try out the autofocus attribute:
<textarea autofocus>
At w3schools.com you will learn how to make websites.
</textarea>
You would need to provide some way to select your textarea, like an ID: <textarea id="my-textarea"></textarea>
.
Then you can use the DOM API: document.getElementById('my-textarea').focus()
.
Or use jQuery: $('#my-textarea').focus()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.