Insert text in textarea at caret position [duplicate]
Possible Duplicate:
How to insert text at the current caret position in a textarea
I want to insert text in a textarea using javascript at the caret position, i already have the code to find the position, whats the code to put text at that particular position?
Thanks,
Jake
var myTextarea = ... // select the text area
$(myTextarea).html('The text I want to insert'); // this will replace the existing contents
To append text to the textarea, use this:
$(myTextarea).html($(myTextarea.html() + 'The text I want to insert');
精彩评论