1
votes

I have different iframes that embed youtube videos or slideshare presentation. I was able to get src from iframes but I want to show for any iframe a div with the correct src url. Actually I'm using this code:

    $.each($("iframe"), function() {
        var src = $(this).attr('src');
        $(this).attr('src', src);  
        console.log(src);
        $(".avia-iframe-wrap").before('<div>' + src + '</div>');
    });

Problem is that I get all the src url of the page above any iframe, see the attached image: attachment

Basically I need to show only youtube url above youtube iframe and only slideshare url above slideshare iframe. Thank you for your help.

1
Can you include your HTML - to get the exact result will depend on where the iframe is in relation to the iframe-wrap. You might want .before or you might want .prepend etcfreedomn-m

1 Answers

0
votes
$("iframe").each(function(){
    var link = $(this).attr("src");
    $(this).find(".avia-iframe-wrap").before('<div>' + src + '</div>');
});