Click here to Skip to main content
15,850,360 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm having a hard time on how to create a div around a iframe without interrupting the iframe playing the YouTube video I know the code is wrong for this situation but i'm just clueless how I can do this.

This is my code

     margin-top: 25px;
      display: block;
    function addADivAroundAIframe() { 

            var iframe= document.querySelector('iframe');
            var parent = iframe.parentNode;
            var div= document.createElement('div');


    <iframe src=''></iframe>

What I have tried:

Google, other help sites, books
David_Wimbley 2-Dec-18 23:07pm    
Why not just wrap the iframe in a div ahead of time?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900