2014-06-22 110 views
1

在頁面中使用TinyMCE編輯器,但我需要使用JQuery獲取值。從TinyMCE獲取價值

我完全失去了如何做到這一點,我試圖使用各種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); 
     }); 
     // 
    } 
+0

好不容易找到本網站上的答案,不能早點找到它。 http://stackoverflow.com/questions/6830541/getting-value-of-textarea-which-is-under-control-of-tinymce-editor-using-jquery – Derple

回答

4

試試這個從文本區域

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