切换HTML5音频的“静音”属性 [英] Toggling the 'muted' attribute of HTML5 audio
本文介绍了切换HTML5音频的“静音”属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个静音/取消静音按钮,我对jquery很新,所以如果有人能给我任何指示,那会很有帮助:
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);
});
推荐答案
修复它,'muted'属性实际上是property:
fixed it, the 'muted' attribute is actually a property:
$("#dinner").click(function() {
var bool = $("#player").prop("muted");
$("#player").prop("muted",!bool);
});
这篇关于切换HTML5音频的“静音”属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文