How to mute an html5 video player using jQuery How to mute an html5 video player using jQuery javascript javascript

How to mute an html5 video player using jQuery


$("video").prop('muted', true); //mute

AND

$("video").prop('muted', false); //unmute

See all events here

(side note: use attr if in jQuery < 1.6)


If you don't want to jQuery, here's the vanilla JavaScript:

///Mutevar video = document.getElementById("your-video-id");video.muted= true;//Unmutevar video = document.getElementById("your-video-id");video.muted= false;

It will work for audio too, just put the element's id and it will work (and change the var name if you want, to 'media' or something suited for both audio/video as you like).


Are you using the default controls boolean attribute on the video tag? If so, I believe all the supporting browsers have mute buttons. If you need to wire it up, set .muted to true on the element in javascript (use .prop for jquery because it's an IDL attribute.) The speaker icon on the volume control is the mute button on chrome,ff, safari, and opera for example