Reputation: 110093
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.
Upvotes: 3
Views: 1323
Reputation: 514
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()
.
Upvotes: 3