Video currentTime Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video


The currentTime property sets or gets the current position in seconds of the video playback.

playback will jump to the specified position when setting.

Set the currentTime property with the following Values

Value Description
seconds Sets the position for the playback of the video, in seconds

Return Value

A Number, representing the current playback time in seconds

The following code shows how to Set time position to 5 seconds:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<video id="myVideo" width="320" height="240" controls>
  <source src="your.mp4" type="video/mp4">
  <source src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.

<button onclick="getCurTime()" type="button">Get current time position</button>
<button onclick="setCurTime()" type="button">Set time position to 5 seconds</button>

var x = document.getElementById("myVideo");

function getCurTime() {//from  ww w  . j  a  v a2s  .  c  o m

function setCurTime() {
    x.currentTime = 5;


Related Tutorials