如何将文本插入 bootstrap wysihtml5 编辑器?
How can I insert text into the bootstrap wysihtml5 editor?
通过单击按钮,我想将文本插入到 wysihtml5 文本区域中。但是发生了一个错误,我不知道如何解决:
$(".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);
});
通过单击按钮,我想将文本插入到 wysihtml5 文本区域中。但是发生了一个错误,我不知道如何解决:
$(".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);
});