在文本区域中的光标位置之后插入文本 [英] Inserting text after cursor position in text area
本文介绍了在文本区域中的光标位置之后插入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的脚本将文本插入文本区域的末尾。我需要在文本区域中当前光标位置后更改为
插入文本。
The script below inserts text to the end of text area. I need to change to insert text after current cursor position in the text area.
jQuery(document).ready(function($){
$('#addCommentImage').click(function(){
var imageLoc = prompt('Enter the Image URL:');
if ( imageLoc ) {
$('#comment').val($('#comment').val() + '[img]' + imageLoc + '[/img]');
}
return false;
});
});
推荐答案
您可以结帐这个答案。 insertAtCaret
jquery插件似乎非常好。
You may checkout this answer. The insertAtCaret
jquery plugin seems very nice.
这篇关于在文本区域中的光标位置之后插入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文