CKEDITOR.replace() 隐藏了我想要转换的文本区域
我正在使用 Javascript 创建一个文本区域,我想将其用作 ckeditor。我的代码类似于
var html = '<textarea name="text"></textarea>';
$('#mydiv').append(html);
var textareas = document.getElementsByTagName('textarea');
// Could be more than one textarea
for (i = 0; i<textareas.lenght; i++) {
var textarea = textareas[i];
CKEDITOR.replace(textarea.name);
}
当我运行此代码并检查输出时,文本区域被隐藏。在萤火虫中检查它,我得到了 style="visibilty:hidden"。然而删除它只会给我一个文本区域而不是一个ckeditor。有谁对如何解决它有任何建议。
将其作为 div 可以工作,但所有示例似乎都在文本区域中。
I'm using Javascript to create a textarea that I want to be a ckeditor. My code is something like
var html = '<textarea name="text"></textarea>';
$('#mydiv').append(html);
var textareas = document.getElementsByTagName('textarea');
// Could be more than one textarea
for (i = 0; i<textareas.lenght; i++) {
var textarea = textareas[i];
CKEDITOR.replace(textarea.name);
}
When I run this code and check the output the textarea is hidden. Inspecting it in firebug I'm getting a style="visibilty:hidden". However removing this just gives me a textarea and not a ckeditor. Does anyone have any suggestions on how to solve it.
Putting it as a div worked but the examples all seemed to be in textareas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
隐藏是正确的。因为
正如您在文档 您不需要附加
The hiding is correct. Because the
<textarea/>
has no wysiwyg support. The.replace()
method replaces the<textarea/>
with it's wysiwyg Editor. That's why it's hidden.As you can see in the documentation you don't need to append the
<textarea/>
, instead you could use your div directly: