jquery

jquery如何获取富文本编辑器的内容

养鱼的猫咪
902
2021-05-19 18:41:55
栏目: 编程语言

在jquery中获取富文本编辑器内容的方法:1.新建html项目,引入jquery;2.使用UE.getEditor方法创建富文本编辑器;3.初始化编辑器;4.使用hasContents()方法判断内容;5.使用getContent()方法获取富文本编辑器内容;


jquery如何获取富文本编辑器的内容


具体步骤如下:

1.首先,新建一个html项目,并在项目中引入jquery;



<script type="text/javascript" src="/static/jquery-2.1.4.min.js"></script>

2.引入jquery后,在项目中创建使用UE.getEditor方法创建一个富文本编辑器;


UE.getEditor('editor', {

})


3.富文本编辑器创建好后,对编辑器进行初始化;


UE.getEditor('editor', {

initialFrameWidth:"100%"

})


4.初始化编辑器后,使用hasContents()方法判断编辑器中是否有内容;


UE.getEditor('editor').hasContents()


5.最后,若编辑器中存在内容,使用getContent()方法即可获取富文本编辑器的内容;


UE.getEditor('editor').getContent()


相关扩展:

1)以纯文本格式获取编辑器内容


UE.getEditor('editor').getContentTxt()


2)启用富文本编辑器


UE.getEditor('editor').setEnabled();


3)删除富文本编辑器


UE.getEditor('editor').destroy();



0
看了该问题的人还看了