JQuery - Switch text on click not working properly
<p>If you take a look at <a href="http://mountainfoodstorage.com/index.php/media" rel="nofollow">this page here</a> you will see that I have a Youtube gallery setup which for the most part works. When you click onto a thumbnail, it switches the video but it doesn't switch the text at the right side properly. It seems to be loading text behind the video and in some cases requires two clicks to switch the text on the right.</p>

<p>Looking at my jQuery below, may someone please help me with determining the issue?</p>

<p>Thanks!</p>

<pre><code>&lt;script&gt;
function replaceVideo(id) {
  originalSrc = jQuery("iframe", "#" + id).attr("src");
  autoPlay = originalSrc + "&amp;autoplay=1";
  jQuery("iframe", "#" + id).attr("src", autoPlay);
  video = jQuery(".video-content", "#" + id).html();
  text = jQuery(".video-description").html();
  jQuery(".vid_desc").html(text);
  jQuery(".flex-video").html(video);
  jQuery("iframe", "#" + id).attr("src", originalSrc);
}

jQuery(".video-list li").click(function() {
  id = jQuery(this).attr("id");
  replaceVideo(id);
});

jQuery(window).load(function() {
  if(window.location.search.substring(1)) {
        element = window.location.search.substring(1).split('&amp;');
        if (document.getElementById(element[0])) {
            document.onload = replaceVideo(element[0]);
        }
    }
});
&lt;/script&gt;
</code></pre>
