tags:

views:

52

answers:

2

I currently have a wysiwyg iframe where the user can submit input to another area on the page. Once the iframe input is submitted, I set it to clear the content. I want to also automatically focus back into the iframe.

This is the code I currently have:

postContentClr = $("iframe#textarea1IFrame").contents().find("body")
postContentClr.html(" ").focus();
A: 

I'm not sure I understand what you are trying to do, but postContentClr is a jQuery object, so calling html() requires that you access it via jQuery like so:

$(postContentClr).html('').focus();
karnage
wrong. as you state yourself it is already a jQuery object. So no need to rewrap it
jitter
oops. I guess I've been doing it wrong.
karnage
+1  A: 

Figured it out. I had to simply focus on the parent. And Jitter is correct, since I already declared it as a jQuery object, it needn't be wrapped.

Working code:

postContentClr = $("iframe#textarea1IFrame").contents().find("body")
postContentClr.html("").parent().focus();
eknown