I have some HTML code for a video and I need to create a button to mute the voice of this video. I have written some jquery code for this button, but when I click the button, my page reloads and the video starts from the beginning (not muted).
<div class="sl-video">
<video id="mainVideo" width="100%" height="600" autoplay="autoplay" loop="loop">
<source src="../Root/Videos/3/24-08-2016/270484_KL_2015_F.mp4" type="video/mp4">
</video>
</div>
<button id="mute-video">Toggle Mute</button>
And jQuery:
$("video").prop('muted', true);
$("#mute-video").click( function (){
if( $("video").prop('muted') ) {
$("video").prop('muted', false);
} else {
$("video").prop('muted', true);
}
});