Taking out an element that is inside an iframe

Asked

Viewed 302 times

3

I needed to take a title that is inside an iframe, I did it with jquery but it takes too long to disappear or even not disappear. I did so with jquery:

$(document).ready(function () {
    $("iframe").contents().find(".titulo").css("display","none");
});

I’ve tried so too, out of $(Document). ready():

$("iframe").contents().find(".titulo").css("display","none");

But it didn’t help, I think if it goes with css it disappears as soon as the page is loaded, would have like to do with css?
If not, how could I do with jquery that once I entered the page that title was not visible?
Help me please,

  • but $(document).ready refers when the page is ready and not the iframe inside it. Try it like this $('iframe').ready

  • Try it this way: $('iframe').on("load", function(){
 $("iframe").contents().find(".titulo").remove();
});


  • Thanks, Sam’s worked :) I stayed a thousand years to try to fix it there

1 answer

4


I don’t know a way to detect DOM loading inside an iframe, but using .on() you can fire the event "load" when the iframe has been fully loaded, and so remove the desired element:

$('iframe').on("load", function(){
   $("iframe")
   .contents()
   .find(".titulo")
   .remove();
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.