Javascript to replace IMG with YouTube video - Autoplay not working as it should?

Try to wrap your JS code with $(function(){ /* CODE */ } IF it doesn't help just try something different and don't waste your time :) : div id="youtube" style="display:none;"> $(function(){ $('#imageID'). Click(function() { $('#youtube').show(). Find("iframe").

Attr("src","youtube.com/embed/kr-oMG6EYSs?rel=0&show...); $('#imageID').hide(); }); }).

Try to wrap your JS code with $(function(){ /* CODE */ } IF it doesn't help just try something different and don't waste your time :).

The embed source is configured to autoplay, hiding the container div does nothing (at least in theory, probably browsers different than Chrome do not permit the iframe to execute). The solution is to remove completely the iframe from the page, and appending it to the page inside the container when you need it. Var yt = $('#youtube'); // If you cant store the html directly var ythtml = yt.html(); yt.hide().children().remove(); // load iframe once needed $('#imageID').

Click(function(){ $(this).hide(); yt. Html(ythtml).show(); }); Of course there is a real solution: using YT's APIs.

I've got an image where when you click it, it gets hidden and the YouTube video gets shown. I wanted the video to play when you click the image so I have set a parameter on the YT link so it autoplays and this works fine in every browser tested apart from Google Chrome. Any ideas on why Chrome is autoplaying the video before I've even clicked the image?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions