Detecting tinyMCE textareas with JQUERY

On some of our forms we convert our textareas over to tinyMCE textareas. How can I tell in jquery if a given textarea has been converted?

I've notice that tinyMCE will change the display of my original textarea to none upon init and then creates an adjacent span with a class of mceEditor, but the follow jquery statements never seems to find it.

if ( $(formElm).siblings("span .mceEditor").size() > 0) { this};


if( $(formElm).parent().find("span .mceEditor").length > 0 ) { this};


if( $(formElm).parent().children("span .mceEditor").size() > 0 ) { this};


There was a request for what the textarea looks like after tinymce is done with it. Here goes

<td class="fields"> <textarea id="serviceDesc" class="form req blob" style="display: none;"> Warm and yummy in your tummy<br /></textarea> <span id="serviceDesc_parent" class="mceEditor defaultSkin"> <table id="serviceDesc_tbl" class="mceLayout" cellspacing="0" cellpadding="0" style="width: 400px; height: 152px;"> <tbody> <tr class="mceFirst"> <td class="mceIframeContainer mceFirst mceLast"> <iframe id="serviceDesc_ifr" frameborder="0" src="javascript:""" style="width: 100%; height: 129px;"> <html> </html> </iframe> </td> </tr> <tr class="mceLast"> </tr> </tbody>


Quick tip: It may be that you've put a space after the span (in the selector), which makes jQuery look for an element with a class named "mceEditor" in the span.


does $('span.mceEditor+textarea:hidden') do it? this assumes by 'adjacent' you mean the mceEditor span immediately precedes the text area (ala FCKeditor)


Will work with if ( $(formElm + ' span.mceEditor').size() > 0) { this};


I tried the following and it works, If I want to check on a textarea with the id 'tmce', then I appended '_parent' to it and tested it thus:

if( $("#tmce_parent").size() ) { //code in case of a textarea with tinymce }


Can you add a sample of the textarea and span?

人吐槽 人点赞



用户名: 密码:
验证码: 匿名发表


查看评论:Detecting tinyMCE textareas with JQUERY