为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 php 的响应式 WYSIWYG 文本编辑器中设置默认值

如何在 php 的响应式 WYSIWYG 文本编辑器中设置默认值

PHP
qq_遁去的一_1 2021-12-03 18:46:29
我正在使用响应式 WYSIWYG 文本编辑器。我想将默认值放在其编辑器中以更新数据。当我检查时,我得到这样的值:<div id="txtEditor" style="display: none;">Test terms</div>编辑器 div 变成另一个 div,如:<div class="Editor-editor" contenteditable="true" style="overflow: auto;"></div>那么我怎样才能把我的<?php echo 'text'; ?>内部Editor-editordiv 。请帮我弄清楚这件事。我对js不熟悉。谢谢
查看完整描述

1 回答

?
千万里不及你

TA贡献1784条经验 获得超9个赞

  $(document).ready(function() {

                var myEditor  = $("#txtEditor"); 

                myEditor.Editor();


// set initial  text in editor

                myEditor.Editor("setText", "text <?php echo time(); ?>");

// copy editor content to textarea

                myEditor.text(myEditor.Editor("getText"));


// copy editor content to textarea when keyup (is not recommended)

// fire only if you typing in editor not detect toolbars actions (eg. bolding)

 $(".Editor-editor").keyup(function(){

                myEditor.text(myEditor.Editor("getText"));

                });

// better is use same action when onsubmit form, or click in Save button


                });

在提交表单之前,您应该将文本从编辑器复制到 textarea


$('#txtEditor').text($('#txtEditor').Editor("getText"));


查看完整回答
反对 回复 2021-12-03
  • 1 回答
  • 0 关注
  • 198 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信