问题
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