javascript - How to apply a jQuery function to a child page in an iframe? -
here's brainteaser:
i have iframe in window, , navbar links it:
<div class="nav"> <a href="link.html" target="iframe-content" id='debug">#debug<a> </div> <iframe name="iframe-content" src="page.html"></iframe>
i've got simple jquery function inset class when link in nav clicked.
$(window).load(function() { $("#debug").click(function() { $('body').toggleclass("debug"); }); });
now question how toggleclass apply inline frame (page.html) , not parent page?
change
$('body').toggleclass("debug");
to
$('#debug').contents().find('body').toggleclass("debug");
check out jquery documentation .contents()
Comments
Post a Comment