There may be a jQuery way to do this, but I don't know what it is.

However, I do know 2 ways to accomplish this: one DOM way, one IE way.
Both methods must be employed.

$(function() {
 $('input[type="text"]').bind('focus',function() {
  window.o=this;
  if (o.setSelectionRange)     /* DOM */
   setTimeout('o.setSelectionRange(o.value.length,o.value.length)',2);
  else if (o.createTextRange)     /* IE */
  {
   var r=o.createTextRange();
   r.moveStart('character',o.value.length);
   r.select();
  }
 });
});


On Jul 2, 2:55 pm, Paul Malan <[EMAIL PROTECTED]> wrote:
> By default it seems browsers select all the text in a textbox when it
> gains focus by way of a tab-press.  I would like the cursor to be
> positioned at the end of any existing text in the input, instead.  The
> examples I'm turning up on Google don't work and seem needlessly
> complex, and since jQuery simplifies everything else I used to hate
> about Javascript, I thought I'd see if there's a simple way to
> position the cursor in a text input box on focus.  Is it doable?
>
> Thanks...

Reply via email to