views:

184

answers:

3
$("#myinputfield").focus();

Doing that on an input field with it's value already set causes the current value to be selected. How can I focus the field without selecting the text?

+1  A: 

I've searched around a bit and kinda found out that you should re-set your value into the desired field after it is focussed on.

Ben Fransen
A: 

How about something like this where you set the value of the input field to itself after focusing it?

$("#myinputfield").focus().val($("#myinputfield").val());
bensie
A: 

Have you tried this?

var txt = $("#myinputfield").val();
$("#myinputfield").focus();
$("#myinputfield").val( txt );
Christopher W. Allen-Poole