Get CodeMirror instance

后端 未结 6 793
礼貌的吻别
礼貌的吻别 2020-12-23 17:14

I want to get an instance of CodeMirror (it is binded to a textarea \'#code\'). From an onclick-event I want to add a value to the current value of the CodeMirror instance.

6条回答
  •  误落风尘
    2020-12-23 17:59

    Another method I have found elsewhere is as follows:

    //Get a reference to the CodeMirror editor
    var editor = document.querySelector('.CodeMirror').CodeMirror;
    

    This works well when you are creating the CodeMirror instance dynamically or replacing an existing DOM element with a CodeMirror instance.

提交回复
热议问题