0
我有一个在线文本编辑器“CKEditor”通过引用它工作,并为我希望编辑器使用的textarea制作特定类名“ckeditor”,编辑器工作以及与textarea的,但一旦我用Java脚本函数添加textarea的它显示了没有编辑的文本区域,这里是Java脚本代码:在线文本编辑器不能使用我的javascript代码
<script src="https://cdn.ckeditor.com/4.6.2/standard/ckeditor.js"></script>
<script>
function myFunction(){
var target = document.getElementById("target");
target.innerHTML = '<textarea name="editor1" class="ckeditor"></textarea>';
}
</script>
这是html代码:
<!--the editor works with this textarea-->
<textarea name="editor1" class="ckeditor"></textarea>
<button onClick="myFunction()">runFunction</button>
<!--the div I want java script to place the editor by clicking the above button-->
<div id="target">some text</div>
任何解?
因为ckeditor不知道你添加了一个元素,你需要告诉它你添加了它。 – epascarello
Quentin谢谢,我试图添加CKEDITOR.replace()方法,但它仍然不起作用,或者它应该只与下面的类名一起使用,如果您可以为我编写代码。 – shihap
你不能评论答案吗?您是否将该ID添加到元素中?你在设置innerHTML后是否调用了该行? – epascarello