简体   繁体   English

如何使用jquery从tinyMCE文本框中获取值?

[英]How do i get the value from a tinyMCE textbox using jquery?

I am trying to get a the value of a textbox that is using tinyMCE (jQuery Version) but when i do i get no content from the textbox. 我试图获得使用tinyMCE(jQuery版本)的文本框的值,但是当我这样做时,我没有从文本框中获取任何内容。 See my code below; 请参阅下面的代码;

var content = $( "#content_textarea" ).val();
alert(content);

Also i am not using a form and the code is activated using a button. 此外,我没有使用表单,并使用按钮激活代码。

I have also tried this code; 我也尝试过这段代码;

var content = tinyMCE.get('content_textarea').getContent();
alert(content);

What am i doing wrong? 我究竟做错了什么?

Try: 尝试:

var editor='content_textarea';
var content =tinyMCE.activeEditor.getContent();
alert(content);

Or if you don't like that, you can do: 或者,如果你不喜欢,你可以这样做:

tinyMCE.triggerSave();
var content =$('#content_textarea').val();
alert(content);

Both work for me. 两者都适合我。

做就是了:

tinymce.get("original textarea id").getContent()

Based on the documentation here: 根据此处的文档:

http://www.tinymce.com/wiki.php/jQuery_Plugin http://www.tinymce.com/wiki.php/jQuery_Plugin

You should use: 你应该使用:

// Gets the contents from a specific editor
alert($('#someeditor').html());

ive had the same problem with ckeditor... mybe this is of interest. 我和ckeditor有同样的问题... mybe这是有意义的。

CKEDITOR.instances['editor1'].getData(); 。CKEDITOR.instances [ 'editor1']的getData();

helped me out....whereby editor1 is the name of the instance 帮帮我......其中editor1是实例的名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM