kindeditor编辑器获取不到修改后的新文本

  在编辑文章的功能中,文章内容使用了kindeditor编辑器进行处理,但是修改文本后保存时发现获取到的内容还是修改前的文本内容。

引用编辑器的标签:

<textarea id="txtContent" class="cominput" style=" 96%;height:400px;" ></textarea>

初始化编辑器:

KindEditor.ready(function (K) {
            var editor1 = K.create('#txtContent', {
                cssPath: '/kindeditor/plugins/code/prettify.css',
                uploadJson: '/uploadimg?mark=5',
                fileManagerJson: '/kindeditor/ashx/file_manager_json.ashx',
                afterBlur: function () { editor1.sync(); },
                allowFileManager: true,
                urlType: 'domain',
                height: "400px",
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {
                        self.sync();
                        K('form[name=myform]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        K('form[name=myform]')[0].submit();
                    });
                }
            });
        });

获取编辑器编辑后的文本:

var content = $("#txtContent").text();

检查代码后,发现一切看起来都很正常,就是结果不正常。

本来以为是编辑器本身的问题,各种调试,各种查资料,最后无意间将取值的js代码调整了下,发现问题解决了

var content = $("#txtContent").val();

还没明白这里面的原理是什么,欢迎各位大大指点

原文地址:https://www.cnblogs.com/ant-jmf17/p/6957150.html