I'm trying to hide a <div> in the parent of an iframe when that iframe loads. The iframe and parent are in the same domain.
Following the accepted answer to this question, I have this code in the iframe:
<script type="text/javascript" src="jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).load(function(){
$('#remove_me', window.parent.document).hide();
});
</script>
Upon loading the iframe, the <div> is not hidden, though. Am I missing something obvious? Thanks in advance.
Try $(document).ready(...) instead of $(document).load(...). The load event is for "any element associated with a URL: images, scripts, frames, iframes, and the window object."
http://api.jquery.com/load-event/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With