codemirror 可以在多个文本区域上使用吗?
codemirror 可以在多个文本区域上使用吗?我使用许多动态生成的文本区域。
<script type="text/javascript">
var editor = CodeMirror.fromTextArea('code', {
height: "dynamic",
parserfile: "parsecss.js",
stylesheet: "codemirror/css/csscolors.css",
path: "codemirror/js/"
});
</script>
我更喜欢在文本区域上设置一个类以将其连接到 codemirror。是否可以?解决这个问题的另一种方法是设置多个 ID。上面的代码设置了连接到 codemirror 的 ID“code”。
Can codemirror be used on more than one textarea? I use many textareas that are generated dynamically.
<script type="text/javascript">
var editor = CodeMirror.fromTextArea('code', {
height: "dynamic",
parserfile: "parsecss.js",
stylesheet: "codemirror/css/csscolors.css",
path: "codemirror/js/"
});
</script>
I would prefer setting a class on the textarea to connect it to codemirror. Is it possible? The Another way of solving it would be to set multiple IDs. The code above sets the ID "code" to connect to codemirror.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,您可以多次调用
CodeMirror.fromTextArea
来“Codemirror-ify”多个文本区域。如果您希望多个文本区域具有相同的选项,请将 Codemirror.fromTextArea 调用包装在函数中,例如:
然后您可以将其应用到文本区域,例如:
You can actually make multiple calls to
CodeMirror.fromTextArea
to 'Codemirror-ify' multiple textareas.If you want multiple textareas with the same options, wrap the
Codemirror.fromTextArea
call in a function, like:You can then apply it to your textareas like:
可能对某人有帮助,使用 html 类将其附加到多个文本区域:
如果投票被否决,请写下原因..!
Might be helpful to somebody, attach it to multiple textareas using html class:
Please write reason if down voted..!
试试这个代码
Try this code