JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://code.jquery.com/jquery-1.8.3.js"></script>

<div class="text1">text1</div>
<div class="text2">test2</div>
<textarea name="text" id="textarea_id"></textarea>
<button class="add">add</button>

<script>
$("button.add").click(function() {
  var text1 = $('.text1').text();
	var text2 = $('.text2').text();
  var $txt = jQuery("#textarea_id");
  var textAreaTxt = $txt.val();
  var caretPos = $txt[0].selectionStart;
	$txt.val(textAreaTxt.substring(0, caretPos) + text1 + text2 + textAreaTxt.substring(caretPos) );
	
});
</script>