codersarepeople
codersarepeople

Reputation: 2001

Fancybox jQuery from iframe

From one page, I call fancybox to open an iframe in the fancybox. From that page, the one in the fancybox, I try to write some more jQuery code.

$(document).ready(function() {});

is not called if my jQuery code is in the head tag, but if my jQuery code is written before anything, even the DOCTYPE, then it works. Why is this?

Thanks in advance.

Upvotes: 1

Views: 882

Answers (1)

HurnsMobile
HurnsMobile

Reputation: 4381

Not sure I completely understand the question, but accessing content inside of an iframe with jQuery is a bit different than you may expect. You need to call similar to the following to interact with iframe content.

$('#iFrame').contents().append('<div>Hello World</div>');

reference: http://simple.procoding.net/2008/03/21/how-to-access-iframe-in-jquery/

Upvotes: 1

Related Questions