从TinyMCE获得价值

时间:2014-06-22 00:55:09

标签: jquery tinymce

我在页面中使用TinyMCE编辑器,但我需要使用JQuery获取值。

我完全迷失了如何做到这一点,我尝试使用各种id并尝试获取值,但它只是不会使用任何东西。

JSfiddle

$( document ).ready( function() {
    tinyMCE.init({
            // General options
           mode : "exact",
            elements : "thisID",

             // Skin options
            skin : "o2k7",
            skin_variant : "silver",    
    });

    derp();
});


    function derp() {
        $('#go').click( function() {
//             alert('derp');
          x = $('#thisID_ifr').val(); //this is where i attempt to get the value of the textarea but its not working?!?
            alert(x);
        });
        //
    }

1 个答案:

答案 0 :(得分:5)

尝试此操作以从文本区域获取值

tinyMCE.activeEditor.getContent();

// Get the raw contents from the editor
tinyMCE.activeEditor.getContent({format : 'raw'});

//Get the text content from the editor
tinyMCE.activeEditor.getContent({format : 'text'});

// Get content of a specific editor:
tinyMCE.get('thisID').getContent();

以下是 Demo