TextTrackList: removetrack event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The removetrack event is fired when a track is removed from a TextTrackList.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("removetrack", (event) => {});

onremovetrack = (event) => {};

Event type

Event properties

In addition to the properties listed below, properties from the parent interface, Event, are available.

track Read only

The TextTrack object to which the event refers.

Examples

Using addEventListener():

js
const mediaElement = document.querySelector("video, audio");

mediaElement.textTracks.addEventListener("removetrack", (event) => {
  console.log(`Text track: ${event.track.label} removed`);
});

Using the onremovetrack event handler property:

js
const mediaElement = document.querySelector("video, audio");

mediaElement.textTracks.onremovetrack = (event) => {
  console.log(`Text track: ${event.track.label} removed`);
};

Specifications

Specification
HTML Standard
# event-media-removetrack
HTML Standard
# handler-tracklist-onremovetrack

Browser compatibility

BCD tables only load in the browser

See also