Heim  >  Artikel  >  Backend-Entwicklung  >  施用百度的UEditor,在前端用jquery获取不了textarea的内容

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

WBOY
WBOYOriginal
2016-06-13 11:08:191515Durchsuche

使用百度的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取的数据,不知道怎么把数据重新添加到编辑器里,因为总是添加不成功……
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn