summernote div更改时Textarea值更改 [英] Textarea value change when summernote div is changed

查看:492
本文介绍了summernote div更改时Textarea值更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了一个div,用于夏天改变从数据库中拉出的文本。

I have setup a div for the summernote to alter text pulled from a database.

<div id="summernote" class="form-control"><?php echo $laws['content']; ?></div> 

$(document).ready(function() {
   $('#summernote').summernote({
     height: 300,
   });
});

我有一个带有ID的文本区域。

directly following the div I have a text area with an ID.

<textarea id="lawsContent"></textarea>

我希望textarea的内容随着我在summernote div中键入而改变。就像我在打字这个问题发生了什么。

I want the content of the textarea to change as I type in the summernote div. Just like what is happening while I am typing this question.

推荐答案

使用 summernote API

我想出了这个解决方案:

I came up with this solution:

$(document).ready(function() {
    $('#summernote').summernote({
      onKeyup: function(e) {
        $("#lawsContent").val($("#summernote").code());
      },
      height: 300,
    });
});

这篇关于summernote div更改时Textarea值更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆