MichaelHoughton
MichaelHoughton

Reputation: 101

Automatically setting cursor on a text form field

Is it possible to automatically set the cursor in a text form field so that the user can start typing without first clicking on the text field (or pressing tab)

I assume with Javascript / JQuery it might be possible?

Upvotes: 1

Views: 76

Answers (2)

potashin
potashin

Reputation: 44581

You can just add autofocus attribute :

<input type="text" autofocus />

Upvotes: 1

Think Different
Think Different

Reputation: 2815

Yes it is

IN jQuery:

$('#YOUR_ELEMENT_ID').focus();

IN JAVASCRIPT:

document.getElementById('YOUR_ELEMENT_ID').focus();

Upvotes: 1

Related Questions