K
K
Kirill2020-05-01 00:27:52
JavaScript
Kirill, 2020-05-01 00:27:52

How to hide a video after it ends?

By clicking on the button, a video appears and plays. And when I'm done, I want to hide it. With js and jq at odds, but with the Internet I built this:

$('.video-button').click(function() {
      this.style.display = 'none';
      $('.video').css('display', 'block');
      $('.video').prop('src', '/img/video.mp4');
      $('.video').on('ended',function(){ 
        $('.video').css('display', 'none');
        });
    });

What needs to be written / changed to hide the video after the end?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question