Need jQuery solution for placing cursor in text field

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
drayarms
Forum Contributor
Posts: 134
Joined: Fri Dec 31, 2010 5:11 pm

Need jQuery solution for placing cursor in text field

Post by drayarms »

hello people, I'm using the following line to change the value of a text input from it's default, to an empty string when an event takes place:

Code: Select all

onevent = ("#target_id").val("");
But the overall goal is to actually get cursor to position itself in the text field when the even is triggered, not just to simply erase the default value of the text field. How can that be achieved?
greip
Forum Commoner
Posts: 39
Joined: Tue Aug 23, 2011 8:23 am
Location: Oslo, Norway

Re: Need jQuery solution for placing cursor in text field

Post by greip »

Like this:

Code: Select all

("#target_id").focus()
Post Reply