Skip to content

Instantly share code, notes, and snippets.

@chrislawes
Created May 29, 2015 22:10
Show Gist options
  • Save chrislawes/a201263b7ae20363a43f to your computer and use it in GitHub Desktop.
Save chrislawes/a201263b7ae20363a43f to your computer and use it in GitHub Desktop.
var mainVideo = $('video');
$(document).on('click', '.js-video-trigger', function(event)
{
// find new video file name from link id
var video = $(this).attr('id');
mainVideo
.find('source').each(function()
{
var format = $(this).attr('src').split('.').pop(); // find this file extension
$(this).attr('src', 'assets/videos/' + video + '.' + format); // change source
});
// reload video
mainVideo[0].load();
event.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment