1

I need the contents of a div to display after an HTML video ends. I saw this post which is a start, but I'm lost on the actual function: Detect when an HTML5 video finishes

<video src="video.ogv" id="myVideo">
  video not supported
</video>

<script type='text/javascript'>
    document.getElementById('myVideo').addEventListener('ended',myHandler,false);
    function myHandler(e) {
        // need to show a hidden div!
    }
</script>
Community
  • 1
  • 1
user2554201
  • 33
  • 1
  • 8
  • get the hidden div with it's `id` and show it, using something like `$('#divID').show();` – Patel Aug 04 '15 at 21:01

2 Answers2

1

You can hide div by id when the page loads, and show it again when video ends.

<video src="video.ogv" id="myVideo">
  video not supported
</video>

<div id="divId">
    Hello world!
</div>

<script type='text/javascript'>
    $(document).ready(function() {
        $("#divId").hide();
    });

    document.getElementById('myVideo').addEventListener('ended',myHandler,false);

    function myHandler(e) {
        $("#divId").show();
    }
</script>
lingo
  • 1,848
  • 6
  • 28
  • 56
1

This should do the trick... I used example "classes" and "ids" since I don't have your full source code.

//CODE

<!DOCTYPE html>
<html>
<head>
<style>
.div-hide{
    display: none;
}
</style>
<script type='text/javascript'>
    document.getElementById('myVideo').addEventListener('ended',myHandler,false);

    function myHandler(e){
        var div = document.getElementById("selectme");
        div.classList.remove("div-hide");
        div.innerHTML = "I'm showing";
    }
</script>
</head>
<body>
    <video src="video.ogv" id="myVideo">
      video not supported
    </video>
    <div id="selectme" class="div-hide">I'm Hidden</div>
</body>
</html>
Jordan Davis
  • 1,485
  • 7
  • 21
  • 40