title: How to get current time of video as event to function&
body: <p>everyone!
  I am new to javascript. Suppose I have a video and I want that when it is played for a certain number of seconds (say 5 seconds), my_function will execute (for example, the word 'five' should be displayed in the console).
  For some reason, the code below correctly displays a current number of seconds of video, but does not display the word in the console.</p>
  
  <p>html:</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Text&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class="container"&gt;
          &lt;video width="400" controls id="video"&gt;
            &lt;source src="video/video.mp4" type="video/mp4"&gt;
            Your browser does not support HTML5 video.
      &lt;/video&gt;
      &lt;span class="timelapse" id='current'&gt; &lt;/span&gt;
      &lt;/div&gt;
      &lt;button id='getTime'&gt;getTime&lt;/button&gt;
  &lt;/body&gt;
  
   &lt;script src="js/script.js"&gt;&lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>script.js:</p>
  
  <pre><code>    var aud = document.getElementById('video');
  
  aud.ontimeupdate = function(){myFunction()};
  
  function myFunction(){
      document.getElementById('current').innerHTML = aud.currentTime;
      if (aud.currentTime == 5.0){
          console.log('Hello!');
      }
  };
  </code></pre>
  
  <p>Thank you!</p>