Toggling the 'muted' attribute of HTML5 au

2019-06-14 01:54发布

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条回答
狗以群分
2楼-- · 2019-06-14 02:16

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

$("#dinner").click(function() {
        var bool = $("#player").prop("muted");
        $("#player").prop("muted",!bool);
});
查看更多
登录 后发表回答