插入文本在文本区域在插入位置
问题描述:
可能重复:
How to insert text at the current caret position in a textarea插入文本在文本区域在插入位置
我想插入使用javascript在光标位置的textarea的文本,我已经有了代码找到位置,什么是在特定位置放置文本的代码?
感谢,
杰克
答
var myTextarea = ... // select the text area
$(myTextarea).html('The text I want to insert'); // this will replace the existing contents
将文本追加到textarea的,使用此:
$(myTextarea).html($(myTextarea.html() + 'The text I want to insert');
试试这个: http://stackoverflow.com/questions/1882890/jQuery的插入文本到文本区域 – jfar