JQuery Click to load video / edit thumbnail, not working
I am working on this Vimeo integration. I am trying to swap the positions of a video when you click on a specific thumbnail. Using the quick and dirty method of swapping classes with addClass and removeClass. Also replace video with html function.
Trying to do this without reloading the page. It looks like html updates, but the video doesn't update properly. Anyone have any thoughts?
Here's the HTML:
<div class="thumbnails">
<div class="jake"><img style="display:inline; position: relative;" src="wp-content/themes/skeleton/images/jake.jpg" /></div>
<div class="katy"><img style="display:inline; position: relative;" src="wp-content/themes/skeleton/images/katy.jpg" /></div>
<div class="cary"><img style="display:inline; position: relative;" src="wp-content/themes/skeleton/images/cary.jpg" /></div>
</div>
And the jQuery code (I only included one section of code, it was repeated for each video thumbnail):
//CARY
jQuery(".cary").click(function(){
jQuery('#videoplayer').html('<iframe src="http://player.vimeo.com/video/57695418?api=1" width="470" height="264" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
if(!(jQuery('div').hasClass('jake'))) {
jQuery('.cary').html('<img style="display:inline; position: relative;" src="wp-content/themes/skeleton/images/jake.jpg" />');
jQuery('.cary').addClass('jake');
jQuery('.jake').removeClass('cary');
}
if(!(jQuery('div').hasClass('katy'))) {
jQuery('.cary').html('<img style="display:inline; position: relative;" src="wp-content/themes/skeleton/images/katy.jpg" />');
jQuery('.cary').addClass('katy');
jQuery('.katy').removeClass('cary');
}
if(!(jQuery('div').hasClass('roderick'))) {
jQuery('.cary').html('<img style="display:inline; position: relative;" src="wp-content/themes/skeleton/images/roderick.jpg" />');
jQuery('.cary').addClass('roderick');
jQuery('.roderick').removeClass('cary');
}
});
+3
source to share