UEditor js动态创建和textarea中渲染【原】

时间:2021-07-20 19:14:43

UEditor动态创建和textarea中渲染

http://ueditor.baidu.com/website/examples/textareaDemo.html

<!DOCTYPE>
<html>
<head>
<title>UEditor js动态创建和textarea中渲染</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="D:/OldPC/D/html/jQuery/jquery-3.1.0.js" ></script>
<script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
<style type="text/css">
#myEditor{
width: 500px;
height: 300px;
}
</style>
</head>
<body>
<div>
<h1>UEditor编辑器 js动态创建和DIV区渲染</h1>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
</div>
<div id="mydiv">
UEditor编辑器 js动态创建
</div>
<textarea id="myEditor">这里是原始的textarea中的内容,可以从数据中读取</textarea>
<div>
<button onclick="createEditor()">js动态创建编辑器</button>
<button onclick="renderEditor()">直接在textarea中渲染编辑器</button>
</div> <script type="text/javascript">
function createEditor() {
var myscript = $("<script id='editor' type='text/plain' style='width:1024px;height:500px;'><\/script>");
$("#mydiv").append(myscript);
UE.getEditor('editor');
} function renderEditor() {
UE.getEditor('myEditor', {serverUrl: '/server/ueditor/controller.php'})
} </script>
</body>
</html>