I have a script where i can just click on a div and add information to a textarea. This is working, however the cursor is always at the start of the information that I inserted.
<div id="click">Click to insert</div>
<textarea id="info">I want to</textarea>
here is the jquery:
<script>
$(document).ready(function(){
$('#click').on('click',function(){
var i=$('#info').val();
var n="Insert this";//information to be inserted
$('#info').val(i + n).focus();
});
});
</script>
Now the entire thing should read I want to insert this followed by the cursor. Instead the cursor is in the middle like this I want to [cursor] insert this. Is there any way that I can have the cursor focus at the end of the contents in the fields?