See demo here.
The editor is under development. Now we check if it has an value - this works well with all form fields that have the class .required... but it does not work with the iframe.
the iframe has a div with id #content.
$('form .meet').focus(function() {
$('iframe').each(function() {
** if($(this).contents().find('#content').val() == '') { **
$(this).addClass('warning');
}开发者_C百科
})
});
That means it should add the class .warning if the iframe is empty. But it always does, so what am i doing wrong?
Does it not work, because the JS does not see the text i currently typed in? ^^
Regards Henry
You're not doing anything wrong, per se, but #content is the <body>
tag of your iframe, and I'm not sure what happens when you call .val()
on the <body>
element. Try substituting .val()
with .text()
and you should get the results you want.
$('iframe').each(function() {
if($(this).contents().find('#content').text() == '') {
$(this).addClass('warning');
}
});
I verified that this works using Firebug, but let me know if it works on the actual page.
精彩评论