Hi,
I am trying to write some JS that will allow background video to only play when it is being hovered over. I have it working with regular video, but I can’t make it work with background video, which is important for what I’m trying to do. First I am trying to pause the video, which works. Then I am trying to make it start again on hover and stop when the hover leaves. These last parts aren’t working. Any idea what’s going wrong? Any advice would be greatly appreciated. Thanks so much!
window.onload = function(){
$("video").each(function () { this.pause() });
}
$(function(){
$("video").hover(function(){
$(this).css("opacity","1");
this.play();
},function(){
$(this).css("opacity","1");
this.pause()
});
});