简体   繁体   English

如何隐藏/取消隐藏codemirror

[英]How to hide/unhide codemirror

I want to hide/unhide a codemirror instance completely. 我想完全隐藏/取消隐藏codemirror实例。 Is there any predefined method doing that, or do I need to somehow select the div and make it hidden. 是否有任何预定义的方法,或者我需要以某种方式选择div并使其隐藏。

according to the documentation, CodeMirror's main editor object has a method that returns to you the main wrapper DOM element. 根据文档,CodeMirror的主编辑器对象有一个方法,它返回主包装器DOM元素。

cm.getWrapperElement()

From there, you should be able to just hide the element like you would hide any html element. 从那里,你应该能够像隐藏任何html元素一样隐藏元素。

Building upon Lochemage's answer, the following code will perform hide/show of Codemirror instance. 在Lochemage的答案的基础上,以下代码将执行Codemirror实例的隐藏/显示。

var cm = $('.CodeMirror')[0].CodeMirror;

//Hide
$(cm.getWrapperElement()).hide();

//Show
$(cm.getWrapperElement()).show();

This works 这有效

var cm = $('.CodeMirror')[0];
var cm$ = $(cm.getWrapperElement());
//Hide
cm$.hide();
//Show
cm$.show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM