2
可能重複:
How to insert text at the current caret position in a textarea插入文本在文本區域在插入位置
我想插入使用javascript在光標位置的textarea的文本,我已經有了代碼找到位置,什麼是在特定位置放置文本的代碼?
感謝,
傑克
可能重複:
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