使用jquery获取textarea的值,而不是发送表单 [英] Getting value of textarea which is under control of tinymce editor using jquery without sending form
问题描述
我有一些textarea
I have some textarea
<textarea name='text' id='text' ></textarea>
受到tinymce脚本的控制。
which is under control of tinymce script.
我有简单的javascript
And I have simple javascript
alert ($('#text').val());
这对我没有任何帮助。问题是,tinymce正在将textarea转换成某种东西,所以实际上没有带有id'text'的textarea了。因为即使在textarea中输入了一些文本,当我按下提交按钮时,javascript会发出空警告。
which gives me nothing. Problem is that tinymce is converting textarea into something , so actually there is no textarea with id 'text' anymore. Because of that javascript gives empty alerts when I press submit button even if there is some text typed in textarea.
所以问题是javascript如何获得这样的textarea的值只要我需要它就会飞?
So question is how can javascript get the value of such textarea on the fly whenever I need it ?
推荐答案
应该可以使用 get
[docs] 和 getContent
[docs] 方法:
It should be possible using the get
[docs] and getContent
[docs] methods:
var value = tinymce.get('text').getContent();
这篇关于使用jquery获取textarea的值,而不是发送表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!