title: How to insert text at the current caret position in a textarea
body: <p>On a function call from an image, I am trying to insert the alt tag value from the image into the textarea at the position where the caret currently is.</p>
  
  <p>This is the code that I currently have which inserts the alt tag value to the end of the text area.</p>
  
  <pre><code>    $("#emoticons").children().children().click(function () {
          var ch = $(this).attr("alt");
          $("#txtPost").append(ch);
  
      }); 
  </code></pre>
  
  <p>The 2 things I have been having a problem with is determining the position of the caret, and creating a new string with the value of the textarea before the carets positon + the code I'm inserting + the value of the textarea after the carets position.</p>