I am facing a weird issue with jQuery append() method. I want to append a container containing iframe in a div but somehow its not working, though If instead of appending a div containing iframe, if I replace this with any other normal div its working fine. Jquery/JavaScript code – var imageURL = 'https://www.youtube.com/embed/zZasH6qkn8M'; var setWidth = '90%'; var setHeight = '211px'; var iframeContainer = '<div id="iframecontainer" style="position: relative;left: 50%;border: 0;top: 50%;transform: translate(-50%, -50%)">'+'<iframe id="ytFrameId" class="ytClassa" width="' + setWidth + '" height="' + setHeight + '" src="' + imageURL +'></iframe>'+'</div>'; //var iframeContainer = '<div id="retro">This is retro</div>'; $('#test').append(iframeContainer);