jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery选择器 – 使用jquery选择器获取tinymce textarea的值大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想得到一个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字段工作)。

与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选择器 – 使用jquery选择器获取tinymce textarea的值全部内容,希望文章能够帮你解决jquery选择器 – 使用jquery选择器获取tinymce textarea的值所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。