This code sets where the cursor postion is.
All this code does is reads the text value, clears it then replaces the original value again, so it looks like you are still typing, thus your cursor is set at the end.
1 2 3 4 5 6 7 8 9 10 11 |
<input type="text" class="form-control" id="itemtext" value="Codehaven"> // THIS SETS CURSOR POSITION AT END OF TEXT $('#itemtext').focus(); var val = $('#itemtext').val(); //store the value of the element $('#itemtext').val(''); //clear the value of the element $('#itemtext').val(val); //set that value back. |