How to hide/unhide codemirror

三世轮回 提交于 2020-01-03 15:33:21

问题


I want to hide/unhide a codemirror instance completely. Is there any predefined method doing that, or do I need to somehow select the div and make it hidden.


回答1:


according to the documentation, CodeMirror's main editor object has a method that returns to you the main wrapper DOM element.

cm.getWrapperElement()

From there, you should be able to just hide the element like you would hide any html element.




回答2:


Building upon Lochemage's answer, the following code will perform hide/show of Codemirror instance.

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

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

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



回答3:


This works

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


来源:https://stackoverflow.com/questions/17581194/how-to-hide-unhide-codemirror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!