Take an element that is inside an iframe

Posted on

Question :

I needed to get a title that is inside an iframe, I did it with jquery but it takes a lot to fade or even disappear. I did so with jquery:

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

I’ve tried it too, out of $ (document) .ready ():

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

But it did not help, I think if it goes with css it disappears as soon as the page loads, how could it do with css?
If not, how could I do with jquery that as soon as I entered the page that title was not visible? Home
Please help me,

    

Answer :

I do not know how to detect DOM loading inside an iframe, but using .on() you can fire the "load" event when the iframe has been fully loaded, and thus remove the desired element:

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

    

Leave a Reply

Your email address will not be published. Required fields are marked *