--- title: HTMLMediaElement.controls slug: Web/API/HTMLMediaElement/controls translation_of: Web/API/HTMLMediaElement/controls ---
{{APIRef("HTML DOM")}}

HTMLMediaElement.controls 这个负责控制html中的controlsHTML属性, 它负责控制播放的媒体(视频或音频)的控制条是否显示。.

语法

var ctrls = video.controls;
audio.controls = true;

返回值

类型 {{domxref("Boolean")}}. 是否成功

例子

var obj = document.createElement('video');
obj.controls = true;

规范

Specification Status Comment
{{SpecName('HTML WHATWG', "the-video-element.html#htmlmediaelement", "HTMLMediaElement.controls")}} {{Spec2('HTML WHATWG')}} No change from {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.controls")}} {{Spec2('HTML5 W3C')}} Initial definition.

浏览器兼容

{{Compat("api.HTMLMediaElement.controls")}}

产考文档