Make a Background Video Play Once (No Loop)

Hi All,

Is there a way to make a background video play just once? This doesn’t work for me:

Thanks.

Niall

The code you need for this is as follows

<script type="text/javascript">
document.getElementById('Video').removeAttribute("data-loop");
</script>

Thanks for response. This doesn’t work for me unfortunately. Still looping.

Can you share your read only and webflow staging webflow domain please?

https://hummingbird-site.webflow.io/

https://preview.webflow.com/preview/hummingbird-site?utm_source=hummingbird-site&preview=dbcda7ae174fd64f182e8b268309f79f

Thanks

Here’s a new code:

<script>
Webflow.push(function() {
  document.getElementById('video').querySelector('video').removeAttribute('loop');
});
</script>
3 Likes

Thanks a million. That worked :slight_smile:

1 Like

I’m glad I could help.

Hi, I’m having the same issue but for some reason the code doesn’t seem to work for me. Would it be possible to let me know where I’m going wrong https://preview.webflow.com/preview/marketingmatters2?utm_medium=preview_link&utm_source=dashboard&utm_content=marketingmatters2&preview=8e8a9cde734a09777a13aa19fd2aa73a&mode=preview

Thanks

You’re missing the ID ‘video’:

2 Likes

Hello @aaronocampo I have followed your instructions in regard to the script and ID for video background but it is still looping, any thoughts? TY!!!

https://preview.webflow.com/preview/bionicbottle?utm_medium=preview_link&utm_source=designer&utm_content=bionicbottle&preview=567362024d13bce247e4b4884d583677&pageId=5f6e9623cae265bb6b0ac2eb&mode=preview

Love the code. Only issue is it works on element ID and the thing about taking element ID to trigger things is it only works on 1 thing, not more than 1 video.