Play Background Video on Hover
Play a background video when a user hovers over the video on your Webflow site.
Play a background video when a user hovers over the video on your Webflow site.
How to add it
- Add the Javascript code to the closing body custom code page settings
- Update the class name to your chosen class name
The code
Javascript
<!-- Add to body close section -->
<script>
var Webflow = Webflow || [];
Webflow.push(function() {
// Change .video here to your video class
var figure = $(".video").hover(function() {
$('video', this).get(0).play();
}, function() {
$('video', this).get(0).pause();
}).each(function() {
$('video', this).get(0).pause();
});
});
</script>