[solved]Issue with SlideToggle
Hi, this is my first post here.
I have some code below that works nicely, except in one respect. The purpose of the code is to slideToggle open one of two hidden sub-nav bars when either of two different menu items are clicked upon - instead of a drop down menu. What doesn't work is the hiding of the div that is not required, if it is already open. Viewing in firebug shows that the appropriate classes are being applied - I suspect the reason is that slideToggle has been somehow set and cannot be unset via another object - but perhaps that is not it at all?
Looking forward to hearing from someone - cheers!
$(document).ready(function() {
//add .toggle function to appropriate li element
$('#hozmenu li:nth-child(4)').toggle(function () {
//set 4th menu links colour to be green whilst div is shown
$('#hozmenu li:nth-child(4) a').css('color', '#95d890');
$('#toggle_nav_services').removeClass('toggle_show');
$('#toggle_nav_services').addClass('toggle_hide');
$('#toggle_nav_caseStudies').slideToggle('medium', function() {
$(this).removeClass('toggle_hide');
$(this).addClass('toggle_show');
});
}, function() {
$('#toggle_nav_caseStudies').slideToggle('medium', function() {
$(this).removeClass('toggle_show');
$(this).addClass('toggle_hide');
});
});
$('#hozmenu li:nth-child(2)').toggle(function () {
//set 2nd menu links colour to be green whilst div is shown
$('#hozmenu li:nth-child(2) a').css('color', '#95d890');
$('#toggle_nav_caseStudies').removeClass('toggle_show');
$('#toggle_nav_caseStudies').addClass('toggle_hide');
$('#toggle_nav_services').slideToggle('medium', function() {
$(this).removeClass('toggle_hide');
$(this).addClass('toggle_show');
});
}, function() {
$('#toggle_nav_services').slideToggle('medium', function() {
$(this).removeClass('toggle_show');
$(this).addClass('toggle_hide');
});
});
});