Skip to content Skip to sidebar Skip to footer

JQuery - FadeToggle - Different Actions If Element Is Visible Or Not

I have a button, when you click on that button, I'm doing a fadeToggle() to show or hide a popup. That popup is appearing on top of a flash video that autoplays. So, what I want t

Solution 1:

You could use the jquery :visible selector to find out if #categorySlider is visible or not and depending on that pause or play the video.

$("#categorySlider").fadeToggle('fast', function() {
   var videoPlayer = document.getElementById("videoContainer");
   if ($("#categorySlider").is(":visible"))
        videoPlayer.pause();
   else
        videoPlayer.play(); 
});

Post a Comment for "JQuery - FadeToggle - Different Actions If Element Is Visible Or Not"