简体   繁体   English

如何为视频标签添加一个空属性?

[英]How can I add a empty attribute to my video tag?

I just would like to add the 'autobuffer' attribute to my video tag using javascript. 我只想使用javascript将'autobuffer'属性添加到我的视频代码中。

Basically: 基本上:

var video = document.createElement('video');
video.addAttribute('autoBuffer');

And I'll have: 我将拥有:

<video autoBuffer></video>

I tried: 我试过了:

video.setAttribute('autoBuffer'); => <video autoBuffer="undefined"></video>

Which is wrong... 哪有错

The second parameter to setAttribute must be a string always - currently the undefined you're implicitly passing is converted to one. setAttribute的第二个参数必须始终为字符串-当前,您隐式传递的undefined将转换为一个。 Use 使用

video.setAttribute('autoBuffer', '');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM