JavaScript .onended event - Brown Surfing

JavaScript .onended event

Posted on: January 2nd, 2023
By: Efrain Lemus

I usually use it to show an image after a video plays but you can do other things like play other videos or assign class names.

headerVideo = document.querySelector('#headerVideo');
imgHeader = document.querySelector('#imgHeader');

headerVideo.onended = function (e) {
    headerVideo.style.opacity = "0";
    imgHeader.style.opacity = "1";
};

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published. Required fields are marked *