how to add a word where the cursor is in javascript

52 Views Asked by At

I want to add a word, where the cursor is. It should be something like this:

addWordToTextarea(word){
 var tmpMyTextArea = document.getElementById('myTextArea').innerHTML.value;
 var tmpCursorPositionInTextarea = document.getCursorFromId('myTextArea'); //does something like this function exist?
 if(tmpCursorPositionInTextarea){
  //add word to tmpMyTextarea on position where cursor is;
 } else {
  tmpMyTextArea = word;
 } 
}
0

There are 0 best solutions below