We can insert simple text in Text area at cursor position using javascript
Below is the snippet. var myTextArea = document.getElementById("mymessage"); var textInArea = myTextArea.value; var textToInsert = '$Simple Text$'; var caretPosition = myTextArea.selectionStart; myTextArea.value = textInArea.substring(0, caretPosition) + textToInsert + textInArea.substring(caretPosition);
'selectionStart' property provides the cursor position in Textarea.
Simple But Nice
ReplyDeleteThank you! this simple code very useful for me!!!
ReplyDeleteThank you from Ukraine!
Very useful information that you have shared and it is very useful to me. Thanks for sharing the information with us.
ReplyDeletekindle mobi formatting services