By click on a button I want to insert text into the wysihtml5 textarea. But there is an error occurring that I cannot figure out how to resolve:
$(".textarea").wysihtml5();
$(".module").click(function(){
var text = $(this).text();
$('.textarea').val(text);
});
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script type="https://raw.githubusercontent.com/xing/wysihtml5/master/dist/wysihtml5-0.3.0.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://jhollingworth.github.io/bootstrap-wysihtml5/lib/js/bootstrap.min.js"></script>
<script type="https://raw.github.com/jhollingworth/bootstrap-wysihtml5/master/src/bootstrap-wysihtml5.js"></script>
<textarea class="textarea" placeholder="Insert Text..." style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
<a class="btn btn-default module" data-wysihtml5-command="bold" title="CTRL+B" href="javascript:;" unselectable="on">This text should be inserted into the textarea on click</a>
$(".textarea").wysihtml5();
$(".module").click(function(){
var text = $(this).text();
$('.textarea').data("wysihtml5").editor.setValue(text);
});