Captain Comic Captain Comic - 1 year ago 122
Javascript Question

Inserting text after cursor position in text areа

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.

var imageLoc = prompt('Enter the Image URL:');
if ( imageLoc ) {
$('#comment').val($('#comment').val() + '[img]' + imageLoc + '[/img]');
return false;

Answer Source

You may checkout this answer. The insertAtCaret jquery plugin seems very nice.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download