---
title: "CKeditor的取值和赋值"
author: "conkeyn"
date: "2017-07-05T14:51:56Z"
tags: []
categories: ["编程语言"]
slug: "ckeditor"
draft: false
lastmod: "2017-07-05T14:46:53Z"
id: 2382989
url: "https://conkeyn.iteye.com/blog/2382989"
---

```
<script type="text/javascript">
     var myeditor=CKEDITOR.replace('txtContent', { toolbar: 'Basic' });
</script>
```

 

 

即赋值给一个变量就OK了，然后使用下面的方式读取文本域的值：

```
myeditor.document.getBody().getText(); //取文本形式的值
myeditor.document.getBody().getHtml(); //取包含html代码的值
```

 

如果要赋值那么就是

```
myeditor.setData("需要赋值的内容");
```