点击按钮,我想在wysihtml5 textarea中插入文字。但是发生了一个错误,我无法弄清楚如何解决:
$(".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>
&#13;
答案 0 :(得分:1)
$(".textarea").wysihtml5();
$(".module").click(function(){
var text = $(this).text();
$('.textarea').data("wysihtml5").editor.setValue(text);
});