0
我在表單內的一個textareas上使用了jQuery wysiwyg編輯器插件,我希望對其應用驗證。 wysiwyg jQuery插件正在生成iframe
,所以我需要檢測if there is any text inserted
inside the iframe
而不是文本區域。jQuery - 查找文本是否存在於iFrame內
<div class="wysiwyg" style="width: 581px;">
<ul class="panel" role="menu">
<div style="clear: both;"></div>
<iframe id="id_message_bodyIFrame" frameborder="0" src="javascript:false;" style="min-height: 170px; width: 573px;" tabindex="0">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body style="margin: 0px;">
my text I want to find if exists
<br _moz_dirty="">
</body>
</html>
</iframe>
</div>
<textarea id="id_message_body" title="Please add a message on the text box above." name="message_body" cols="70" rows="10" style="display: none;"></textarea>
<div id="req_message_body" class="req" style="display: none;">This is required</div>
</div>
任何想法如何找到,如果文本已插入iframe中和它旁邊創建一個錯誤消息像<div id="err"> This field is required</div>
?我感謝您的幫助!
謝謝你的快速反應。所以要檢查文本是否已經添加到框架中,我應該這樣做嗎?if($('#id_message_bodyIFrame')。contents()。find('body')。text()。length()<0){ //做些什麼} – avatar 2011-04-23 14:05:32
我會用> 0 – mcgrailm 2011-04-23 14:20:35
@itgorilla是否爲你工作? – mcgrailm 2011-04-23 15:48:29