Q:

How to target text field inside iFrame?

I want to target a text field inside an iFrame and give it a value from prent page. I have tried this one but its not working:
// b_frame is the ID of the iFrame
$('#b_frame').load(function() {<br />
    $(this.contentDocument).find('body#txtUserID').val('dddddd')<br />
});

I would really appreciate any help.

A:

As Felix mentioned, it's only possible when the iFrame is the same domain as the main page.
But, you can do so under normal circumstances using .contents(). There is a demo towards the bottom of the documentation page, just follow the link.

