如何将HTML纯文本插入DB?

时间:2019-03-01 20:22:47

标签: php html mysqli

我正在创建PHP源代码,它将插入我使用鹅毛笔文本编辑器创建的页面。文本编辑器数据正在插入工作,但未插入纯文本。 我想插入HTML纯文本

这是我的JavaScript代码

<script src="https://cdn.quilljs.com/1.2.3/quill.core.js"></script>
<script src="https://cdn.quilljs.com/1.2.3/quill.min.js"></script>
<script src="https://cdn.quilljs.com/1.2.2/quill.js"></script>
<!-- Initialize Quill editor -->
<script>
var quill = new Quill('#editor', {
  modules: {
    toolbar: [
      ['bold', 'italic'],
      ['link', 'blockquote', 'code-block', 'image'],
      [{ list: 'ordered' }, { list: 'bullet' }]
    ]
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'
});

var form = document.querySelector('form');
form.onsubmit = function() {
  // Populate hidden form on submit
  var about = document.querySelector('input[name=content]');
  about.value = JSON.stringify(quill.getContents());


};
</script>

像这样显示结果

{"ops":[{"insert":"yyyyyyyyyyyyyyyy"},{"attributes":{"code-block":true},"insert":"\n"}]}

1 个答案:

答案 0 :(得分:1)

尝试 InnerHTML ,而不使用 jSON.Stringify

about.value = quill.root.innerHTML;
相关问题