--- 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.

浏览器兼容

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatGeckoDesktop("1.9.1")}} [1] {{CompatIE("9")}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

产考文档