How to get the content of a Tinymce textarea with JavaScript

后端 未结 10 2096
忘掉有多难
忘掉有多难 2020-12-02 20:08

i have an array of content then how we get content of Tinymce textarea in javascript

10条回答
  •  眼角桃花
    2020-12-02 20:48

    Use the getContent() method from the TinyMCE API.

    Let’s say you have initialized the editor on a textarea with id=”myTextarea”. First access the editor using that same id, then call getContent(). For example:

    var myContent = tinymce.get('myTextarea').getContent();

    Or, instead of accessing the editor by id, you can access the active editor:

    var myContent = tinymce.activeEditor.getContent();

    If want to get the TinyMCE content without the HTML tags, you can pass in a parameter to indicate that you want the result in plaintext. For example:

    var myContent = tinymce.get('myTextarea').getContent({format: 'text'});

    More info and examples here: https://www.tiny.cloud/blog/how-to-get-content-and-set-content-in-tinymce.

提交回复
热议问题