Created
February 7, 2015 02:19
-
-
Save simsketch/78bf8e6d0fba809389fe to your computer and use it in GitHub Desktop.
Have a video play on hover
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
// something along that | |
var vid = document.getElementsByTagName("video"); | |
[].forEach.call(vid, function (item) { | |
item.addEventListener('mouseover', hoverVideo, false); | |
item.addEventListener('mouseout', hideVideo, false); | |
}); | |
function hoverVideo(e) | |
{ | |
this.play(); | |
} | |
function hideVideo(e) | |
{ | |
this.pause(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment