使用 javascript 中的 ckeditor 获取存储在数据库中的带有 html 标签的数据

Get data with html tag stored in db by using ckeditor in javascript

有一个 ckeditor 将文本与 HTML 标签一起存储在数据库中。

例如: 数据库中的描述字段有以下数据

<p><strong>Name:</strong> <i>James Sun.</i></p>
<p>description here</p>

我需要在 javascript onclick 函数中发送此数据。但它在这里给出了一个错误。如果描述字段(数据库 table)有纯文本,它可以工作,但是如何使用 javascript.

通过带有 HTML 标签的 ckeditor 保存数据

HTML

<div onclick="descriptionChanges('<?php echo ($h->description) ?>')" > </div>

javascript

function descriptionChanges(description) {
    console.log(description); // it gives err 
}

您应该使用 javascript 的 innerHTML 属性,示例如下。

<div id="desc">
    <p>this is tesitng</p>
</div>
<script>
var htmldata = document.getElementById('desc').innerHTML
</scirpt>