add or remove controls attribute from html5 <video> tag

寵の児 提交于 2019-12-05 12:25:41

You can do it with jQuery:

//Add
$('#myVideo').prop("controls", true);



//Remove
$('#myVideo').prop("controls", false);

And without jQuery, surprisingly even shorter:

//Add
myVideo.controls = "controls";


//Remove
myVideo.controls = "";
  • Based on that you already created a variable myVideo as you did:

    var myVideo = document.getElementById("myVideo");

Hope that helped :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!