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 October 2018.
Theremovetrack event is fired when a track is removed from aTextTrackList.
In this article
Syntax
Use the event name in methods likeaddEventListener(), or set an event handler property.
js
addEventListener("removetrack", (event) => { })onremovetrack = (event) => { }Event type
ATrackEvent. Inherits fromEvent.
Event properties
In addition to the properties listed below, properties from the parent interface,Event, are available.
Examples
UsingaddEventListener():
js
const mediaElement = document.querySelector("video, audio");mediaElement.textTracks.addEventListener("removetrack", (event) => { console.log(`Text track: ${event.track.label} removed`);});Using theonremovetrack 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> # event-media-removetrack> |
| HTML> # handler-tracklist-onremovetrack> |
Browser compatibility
See also
- Related events:
addtrack,change - This event on
VideoTrackListtargets:removetrack - This event on
AudioTrackListtargets:removetrack - This event on
MediaStreamtargets:removetrack - Media Capture and Streams API
- WebRTC