gpt4 book ai didi

jquery-selectors - 使用 jquery 选择器获取 tinymce textarea 的值

转载 作者:行者123 更新时间:2023-12-03 10:31:14 25 4
gpt4 key购买 nike

我想获得一个 tinymce textarea 的值

<textarea id="thetextarea"></textarea>

上键以便使用以下命令将其输入到显示预览脚本中:
function showPreview(value) {

$("#preview-container").load("/material-preview.php", {s:value});

}
$('thetextarea').live("keyup",function (e) {

var material = this.value;
showPreview(material);

return false;

});

如果我尝试选择 textarea id thetextarea它不起作用(如果我不把它变成一个 tinymce-field 就起作用)。

使用 firebug 我看到文本,当 textarea 被 tinymce 转换时,在:
<body id="tinymce" class="mceContentBody"></body>

但这也不起作用,(也不起作用 $('#tinymce') )
 $('mceContentBody').live("keyup",function (e) {

var material = this.value;
showPreview(material);

return false;

});

根据要求应用 tinyMCE 后的 HTML 代码(来自 Firebug )
 <textarea id="material-input" class="mceEditor text" style="width: 310px ! important; height: 250px ! important; display: none;" name="material" aria-hidden="true"></textarea>
<span id="material-input_parent" class="mceEditor defaultSkin" role="application" aria-labelledby="material-input_voice">
<span id="material-input_voice" class="mceVoiceLabel" style="display:none;">Rich Text Area</span>
<table id="material-input_tbl" class="mceLayout" cellspacing="0" cellpadding="0" role="presentation" style="width: 310px; height: 250px;">
<tbody>
<tr class="mceFirst" role="presentation">
<tr>
<td class="mceIframeContainer mceFirst mceLast">
<iframe id="material-input_ifr" frameborder="0" src="javascript:""" allowtransparency="true" title="Rich Text Area. Press ALT F10 for toolbar. Press ALT 0 for help." style="width: 100%; height: 206px;">
<html>
<head xmlns="http://www.w3.org/1999/xhtml">
<body id="tinymce" class="mceContentBody " contenteditable="true" spellcheck="false" dir="ltr">
<!-- the text inside tinymce textarea -->
</body>
</iframe>
</td>
</tr>
<tr class="mceLast">
</tbody>
</table>
</span>

最佳答案

称呼

tinyMCE.triggerSave();

之后你就可以使用 jquery 选择器
$("#yourtextareaID").val();

关于jquery-selectors - 使用 jquery 选择器获取 tinymce textarea 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7214218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com