I have a full screen youtube video as a background of a website that I'm working on and I'm trying to add a mute/unmute toggle with a button. This is how I'm pulling in the video :
<a id="bgndVideo" class="player" data-property="{videoURL:'https://youtu.be/KW2JUfgQct0',containment:'.video-section', quality:'high', autoPlay:true, mute:true, opacity:1}">bg</a>
I know the logic of how I'd like to run the toggle, when the buttons clicked I would like the data property to change, so if its data-property is mute:true onClick I would like it to change to mute:false and then back when clicked again.
this is what I've tried -
$(document).ready(function(){
$(".muteButton").click( function (){
$(this).data('mute', !$(this).data('mute'));
});
});
with an anchor tag -
<a class="muteButton" href="#">Mute</a>
I've looked up how to do this but had no luck, I've never written jquery so I'm lost, is this an easy thing to do??
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…