Home  >  Article  >  Backend Development  >  施用百度的UEditor,在前端用jquery获取不了textarea的内容

施用百度的UEditor,在前端用jquery获取不了textarea的内容

WBOY
WBOYOriginal
2016-06-13 12:59:52831browse

使用百度的UEditor,在前端用jquery获取不了textarea的内容
代码如下

<br />
<textarea name="filecontent" id="filecontent" > </textarea><br />
<input type="button" value='save' id="insert_file"/><br />

<script type="text/javascript"><br />
    var editor = new UE.ui.Editor();<br />
    editor.render("filecontent");<br />
<br />
$('#insert_file').click(function(){<br />
    var filecontent = $('#filecontent').val();<br />
<br />
         alert(filecontent);<br />
	});<br />
</script>

------解决方案--------------------
他有个demo的,运行那个demo 里面有好多按钮 可以点击获取内容 各种...
然后你直接用他的方法就可以了
------解决方案--------------------
获得编辑器的内容
editor.getContent()

虽然 filecontent 标识的是 textarea
但实际的编辑器在一个 ifarme 中
------解决方案--------------------

引用:
引用:获得编辑器的内容
editor.getContent()

虽然 filecontent 标识的是 textarea
但实际的编辑器在一个 ifarme 中
谢谢,问题解决,但是如果需要修改旧文章的时候,应该怎样把数据重新放入到编辑器里边?因为我用的是ajax取的数据,不知道怎么把数据重新添加到编辑器里,因为总是添加不成功……


你要看看JS有没错误,内容需要转义的
------解决方案--------------------
editor.setContent(待插入的内容)

引用:
引用:获得编辑器的内容
editor.getContent()

虽然 filecontent 标识的是 textarea
但实际的编辑器在一个 ifarme 中
谢谢,问题解决,但是如果需要修改旧文章的时候,应该怎样把数据重新放入到编辑器里边?因为我用的是ajax取的数据,不知道怎么把数据重新添加到编辑器里,因为总是添加不成功……
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn