track attribute | track property

Returns the TextTrack object that corresponds to a track element.

This property is read-only.

HTML5 A vocabulary and associated APIs for HTML and XHTMLInternet Explorer 10



<element track="track" ... >


track = object.track


Property values

Type: TextTrack

A TextTrack object

Standards information


The track element represents a single track that is associated with the video element.

Note  To create timed text files in both Web Video Text Track (WebVTT) and Timed Text Markup Language (TTML) formats, see HTML5 Video Caption Maker on the Windows Internet Explorer test drive site.


The following example gets a TextTrack object from a track element and displays all the cues that the track represents.

<!DOCTYPE html >
<html >
    <title>Get track example</title>
    <h1>Get track example</h1>
    <video id="video1" controls  >
      <source src="">
      <track id="entrack" label="English subtitles" kind="captions" src="entrack.vtt" srclang="en" default>
    <button id="mybutton">Show tracks</button>
    <div style="display:block; overflow:auto; height:200px; width:650px;" id="display"></div>
      document.getElementById("mybutton").addEventListener("click", function () {
        var myTrack = document.getElementById("entrack").track; // get text track from track element          
        var myCues = myTrack.cues;   // get list of cues                    
        for (var i = 0; i < myCues.length; i++) {
        // append track label
        document.getElementById("display").innerHTML += (myCues[i].getCueAsHTML().textContent + "<br/>");  
     }, false);

See also