Created
May 29, 2015 22:10
-
-
Save chrislawes/a201263b7ae20363a43f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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