如何使用Ckeditor保存具有div和html属性的HTML

时间:2019-03-08 10:48:15

标签: javascript html ckeditor

这是我的HTML

<div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne">
        <h4 class="panel-title">
            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                Do I need to print my ticket?
            </a>
        </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
        <div class="panel-body">
            <p>No, showing your e-ticket on your phone is fine. However, printing your ticket can sometimes make the process of entering an event easier/faster. </p>
        </div>
     </div>
 </div>

需要将其保存到数据库中
当我保存它时,CKEditor会自动将<div>转换为<p>

1 个答案:

答案 0 :(得分:1)

为了从名为CkEditor的编辑器中检索数据,您必须使用方法CKEDITOR.editor.getData,它是编辑器的一个实例。

<script>
    var data = CKEDITOR.instances.editor1.getData();
    //Then write your code here to save it 
</script>