How to unmute html5 video with a muted prop
html, javascript, video
Solution
Try this:
function toggleMute() {
var video=document.getElementById("myVideo");
video.muted = !video.muted;
}
Check example here
If your own code is not working, try adding an `id` to your video/element you want the click to register on and using:
var video=document.getElementById("myVideo") ;
$(video).on("click", function(e){
video.muted = !video.muted;
});
Problem
I've created a simple video block with muted (for mobile autostart) but now i can not change the mute state... I used that repository , fiddle link would be great. So far i've tried this with no luck. HTML ``` <video width="640" height="264" muted autoplay webkit-playsinline src="'+videoURL+'"></video>' ``` JS ``` $(document).on("click",".containerVolume",function(e){ if(isMuted){ $('video').prop('muted', false); } else{ $('video').prop('muted',true); } }); var videos = document.querySelectorAll('video'); if (location.search === '?enabled=false') { } else if (location.search === '?enabled=true') { enableVideos(false); } else { enableVideos(); } function enableVideos(everywhere) { for (var i = 0; i < videos.length; i++) { window.makeVideoPlayableInline(videos[i], !videos[i].hasAttribute('muted'), !everywhere); } } ```