JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.dawnsource.com/work/rangyinputs_jquery.js"></script>
<div>
<div class="guides_chapters_button" onclick="surroundtest('[center]', '[/center]');">Center</div>
<div class="guides_chapters_button" style="text-decoration: underline;" onclick="surround('[u]', '[/u]');">u</div>
</div>
<textarea class="guides_chapters_textarea" id="textareamatch" name="matchupm" rows="7" cols="25"></textarea>
JavaScript
window.surround = function surround(text2,text3){
$("#textareamatch").surroundSelectedText(text2, text3);
}
window.surroundtest = function surroundtest(text2,text3){
var c = $(this).parent().next('textarea');
c.surroundSelectedText(text2, text3);
}