jQuery CSS Opacity toggle

I have a pices of script that toggels the opacity of a div when a different div is clicked.  When you click on a menu choice a large menu opens and I change the opacity of the image behind the menu.  The issue is, if I click on a different menu choice, the opacity toggle.  You can see what I mean here:http://cohr-dev-ee01.azurewebsites.net/
Click on the links at the top and when the menu opens click another link up top and then click the same link up top again and you will see what I mean.  I only want the div opacity faded when the menu is open.
jQuery(document).ready(function() {
	jQuery('.laser-nav-display').click(function() {
		jQuery('.nav-lasers').slideToggle("slow", function() {
			$('.nav-applications').hide();
			$('.nav-support').hide();
			$('.nav-company').hide();
			if($('.slider-container').css('opacity') == 1){
				$('.slider-container').animate({opacity:0.3}, 1000);
			} else{
				$('.slider-container').animate({opacity:1}, 1000);
			}
		});
	});
	jQuery('.app-nav-display').click(function() {
		jQuery('.nav-applications').slideToggle("slow", function() {
			$('.nav-lasers').hide();
			$('.nav-support').hide();
			$('.nav-company').hide();
			if($('.slider-container').css('opacity') == 1){
				$('.slider-container').animate({opacity:0.3}, 1000);
			} else{
				$('.slider-container').animate({opacity:1}, 1000);
			}
		});
	});
	jQuery('.support-nav-display').click(function() {
		jQuery('.nav-support').slideToggle("slow", function() {
			$('.nav-lasers').hide();
			$('.nav-applications').hide();
			$('.nav-company').hide();
			if($('.slider-container').css('opacity') == 1){
				$('.slider-container').animate({opacity:0.3}, 1000);
			} else{
				$('.slider-container').animate({opacity:1}, 1000);
			}
		});
	});
	jQuery('.company-nav-display').click(function() {
		jQuery('.nav-company').slideToggle("slow", function() {
			$('.nav-lasers').hide();
			$('.nav-applications').hide();
			$('.nav-support').hide();
			if($('.slider-container').css('opacity') == 1){
				$('.slider-container').animate({opacity:0.3}, 1000);
			} else{
				$('.slider-container').animate({opacity:1}, 1000);
			}
			});
		});

Open in new window

LVL 7
rgranlundAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You need to determine on click if the click was on the menu item that is already open (effectivly a close
What you do is check to see if the item you are going to toggle is already visible.
var vis = $('.laser-nav-display').is(':visible'));

Open in new window

Then when you do the opacity check you first check to see if the item was visible
if (vis) {
  if($('.slider-container').css('opacity') == 1){
    $('.slider-container').animate({opacity:0.3}, 1000);
  } 
  else {
    $('.slider-container').animate({opacity:1}, 1000);
  }
}

Open in new window

Obviously repeat for all the jQuery blocks.
0
Julian HansenCommented:
Correction.
  if($('.slider-container').css('opacity') == 1){
    $('.slider-container').animate({opacity:0.3}, 1000);
  } 
  else {
    if (vis) {
       $('.slider-container').animate({opacity:1}, 1000);
    }
  }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.