Track label 属性

定义和用法

label 属性设置或返回轨道的 label 属性的值。

HTML label 属性规定文本轨道的标签/标题。

当列出可用的文本轨道时,浏览器会使用文本轨道的标题。

另请参阅:

HTML 参考手册:HTML <track> label attribute

实例

例子 1

获取文本轨道的标签:

var x = document.getElementById("myTrack").label;

x 的结果可能是:

English

例子 2

设置文本轨道的标签:

document.getElementById("myTrack").label = "Norwegian";

Syntax

Return label attribute:

trackObject.label

Set label attribute:

trackObject.label = label

Attribute value

Value Description
label Specifies the label/title of the text track.

Technical details

Return value: String value, representing the label/title of the text track.

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Not supported Not supported Supported