Streaming live at 10am (PST)

Background Video loop

Hi all,
I want background vedio play only once but it’s looping .
I used the following code.but some reason that doesn’t seem to work for me.

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

Would it be possible to know where I’m going wrong.

Hi, could you add your read only link?

Maxi

There are a few issues with the code. Here’s the correct code:

<script>
  var Webflow = Webflow || [];
  Webflow.push(function() {
    // Your code here...
    document.querySelector('video').removeAttribute('loop');
  });
</script>

The main issue was that getElementById won’t work because Webflow applies ID to the parent Div instead of the video tag itself. So you’ll need to target video tag using querySelector.

I’ve tested the code and works fine. It probably won’t work if you have more than one video on the page.

P.S. Add the code in the body tag. Might not work in the head tag.