Tuesday 20 August 2013

Toggle Video on Click

Toggle Video on Click

I'm trying to get a button when clicked to swap out a video for another
which is autoplaying and looping.
Really cant seam to figure this one out, any help would be great!
Heres my code,
<script>
$('#button').click(
$('#container').toggle(
function() {
$('#container').html("video src="video/1.mp4" type="video/mp4"
preload="preload" autoplay="autoplay" loop="loop"></video>";
}, // end first click
function() {
$('#container').html("<video src="video/2.mp4" type="video/mp4"
preload="preload" autoplay="autoplay" loop="loop"></video>");
} // end second click
); // end toggle
</script>

No comments:

Post a Comment