jQuery - how to hide an element if ANY of the activating elements are opened?

user3465990

To further clarify this problem, here's the current situation: http://jsfiddle.net/Laqqw/1/

I need to hide the bottom element, when ANY of the navs are opened. And when all the navs are closed, the bottom element would show up again.

toggle() doesn't work, because it sometimes ends up not showing the bottom element when all the navs are closed. I tried using if else with no sensible results. Am I missing something here?

$(document).ready(function() {
    $("p").hide();
    $("h1, h2").click(function() {
      $(this).next().slideToggle(300);
      $("footer").toggle(300);
        $("#nav1, #nav2, #nav3").click(function() {
            $(this).data("clicked", true);
            if ($("#nav1, #nav2, #nav3").data("clicked")) {
                $("footer").hide(300);
            } else {
                $("footer").show(300);
            }
        });
    });
});
DOTNET Team

Try this,

$(document).ready(function() {
    $("p").hide();
    $("h1, h2").click(function() {
        $(this).next().slideToggle(300, function(){
            if($("p:visible").length == 0)
                $("footer").show(300);
            else
                $("footer").hide(300);
        });
    }); 
});

Check jsfiddle

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to hide a div with Jquery based on the elements inside it

Activating hover state over multiple elements using jQuery

How can I hide any DOM element

jQuery - How to hide an element and its children?

jQuery: how to select element by checking for child elements

hide different DOM element to the elements being filtered via jquery

JQuery onClick activating every element on page with class

jQuery, hide a before element

How do I hide the closest element to the element that was clicked without jQuery?

How to show and then hide elements with setTimeout or setInterval and JQuery?

How to replace multiple elements with the same element in jQuery?

How to hide element with jquery depends on cookie value?

How to wrap elements with starting and ending element in jQuery?

How to push element without activating onClick in ReactJS?

How to hide everything within "ul" element if there are no "li" elements contained using jQuery?

How to hide the parent element without $this in jQuery?

How to hide this element using CSS or JQuery

How to hide div element by body clicking in jQuery?

How can I hide a Element with jquery?

how to hide dropdown menu if i click body any element?

How do I hide elements in a given div based on an array of element types with jQuery?

Angular: how to hide DOM element based on the number of filtered elements in model?

How to hide any html element by using another class in javascript?

Hide any html element with Angularjs

jQuery hide an element with slideup

JQuery hide all elements

How to hide and show elements based on current hovered element?

How to hide the DOM element using Jquery - Not duplicate

How do you hide an element using JQuery?