问题描述
在我们的一些表格中,我们将textareas转换为tinyMCE textareas。如何在jquery中判断给定的textarea是否已被转换?
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?
我注意到tinyMCE会在初始化时将原始textarea的显示更改为none,然后使用mceEditor类创建相邻的span,但是跟随jquery语句似乎永远不会找到它。
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){... do this} ;
if ( $(formElm).siblings("span .mceEditor").size() > 0) { ...do this};
或
if($(formElm).parent()。find(span .mceEditor) ).length> 0){...执行此操作};
if( $(formElm).parent().find("span .mceEditor").length > 0 ) {...do this};
或
if($(formElm) ).parent()。children(span .mceEditor)。size()> 0){... do this};
if( $(formElm).parent().children("span .mceEditor").size() > 0 ) {...do this};
在完成了tinymce之后,有一个请求textarea的样子。这里去了
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>
推荐答案
快速提示:可能是你在span之后放置一个空格(在选择器中),这使得jQuery寻找一个带有a的元素跨度中名为mceEditor的类。
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.
这篇关于使用JQUERY检测tinyMCE textareas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!