TextTrackList: change 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 change
event is fired when a text track is made active or inactive, or a TextTrackList
is otherwise changed.
Syntax
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("change", (event) => {});
onchange = (event) => {};
Event type
A generic Event
with no added properties.
Examples
Using addEventListener()
:
js
const mediaElement = document.querySelectorAll("video, audio")[0];
mediaElement.textTracks.addEventListener("change", (event) => {
console.log(`'${event.type}' event fired`);
});
Using the onchange
event handler property:
js
const mediaElement = document.querySelector("video, audio");
mediaElement.textTracks.onchange = (event) => {
console.log(`'${event.type}' event fired`);
};
Specifications
Specification |
---|
HTML # event-media-change |
HTML # handler-tracklist-onchange |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
change event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
- Related events:
addtrack
,removetrack
- This event on
VideoTrackList
targets:change
- This event on
AudioTrackList
targets:change
- Media Capture and Streams API
- WebRTC