Toggling the 'muted' attribute of HTML5 audio

泄露秘密 提交于 2019-12-23 05:23:00

问题


I am trying to create a mute/unmute button, I'm quite new to jquery so it would be helpful if anyone could give me any pointers:

$("#dinner").click(function() {
       var bool = $("#player").muted;
       $("#player").attr("muted",!bool);
});

回答1:


fixed it, the 'muted' attribute is actually a property:

$("#dinner").click(function() {
        var bool = $("#player").prop("muted");
        $("#player").prop("muted",!bool);
});


来源:https://stackoverflow.com/questions/23409992/toggling-the-muted-attribute-of-html5-audio

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