x4k3p x4k3p - 1 year ago 120
jQuery Question

jQuery textbox focus() place cursor anywhere

I have a javascript below:

function modify(value){
$('.ajax').html($('.ajax input').val());
'<input id="editbox"' + ' type="text" value="' + $(value).text() + '"/>');

Problem is that the cursor is placed at the beginning. Is there a solution I can place it wherever I want? F.e. if I click in the middle of the text I want the cursor to be there so I can edit the text from there on.


I can only modify my value if I navigate with the left/right arrows to the position I want. If I click into the middle, the cursor disappers.

Got It! Will paste code later

Answer Source

You can position the cursor at the end of the text:

     this.value = this.value;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download