skip to Main Content

I am working on this website https://limbicmusic.com.br/. I want to stop the background music when we click on links at the bottom of the page. Iam trying this jQuery code. But this code only stops toggle button animation not music on click. Kindly guide.

 jQuery(document).ready(function($) {

$(".mfp-video").click(function(){

$(".music_toggle").removeClass("on");
 
});

})

2

Answers


  1. You are making a change to the sound button, not the actual video. You’ll need to mute the video explicitly like this:

    jQuery(document).ready(function($) {
        $(".mfp-video").click(function() {
            $(".music_toggle").removeClass("on");
            $('body').find('video').prop('muted', true);
        });
    
    })
    
    Login or Signup to reply.
  2. You should use the pause() function and set the currentTime variable value to 0.

    Try this:

    jQuery(document).ready(function($) {
        var myVideo = document.getElementById('video_id'); //ID of <video> tag
        $(".mfp-video").click(function() {
            $(".music_toggle").removeClass("on");
            myVideo.pause();
            myVideo.currentTime = 0;
        });
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search