I have a panel with 3 buttons. Currently I have it so that if you click one of the 3 buttons, it toggles a hidden DIV ("#utilityBK") show and then to animate from the bottom and slide up. I need to add some logic to the function to determine if "#utilityBK" is already showing, and if it is, just to swap out different DIVs that's contained within. Here is the HTML
<div id="utilityBK">
<div id="chatContent"></div>
<div id="locationsContent"></div>
<div id="searchContent"></div>
</div>
Here's one of the functions that currently works just to toggle the utilityBK and that's it.
$(document).ready(function(){
("#chat").click(function(){
if ($("#utilityBK").is(":hidden")) {
$("#utilityBK").animate({'bottom': '60px'}, 'slow');
$('body').addClass('noscroll');
}
else {
$("#utilityBK").animate({'bottom': '-325px'}, 'slow');
$('body').removeClass('noscroll');
}
});
});
And then this is my attempt on adding the additional logic to check to see if #utilityBK, #searchContent or #chatContent is displayed. If so, I just want it to hide those *Content IDs and display the #locationsContent DIV, otherwise animate the #utilityBK back down.
$(document).ready(function(){
$("#locations").click(function(){
if ($("#utilityBK").is(":hidden")) {
$("#utilityBK").animate({'bottom': '60px'}, 'slow');
$('body').addClass('noscroll');
}
else if ($("#searchContent, #chatContent, #utilityNav").not(":hidden")) {
$("#searchContent").css("display","none");
$("#chatContent").css("display","none");
$("#locationsContent").css("display","block");
} else {
$("#utilityBK").animate({'bottom': '-325px'}, 'slow');
$('body').removeClass('noscroll');
}
});
});
So at the moment that particular button doesn't do anything... I'm guessing I'm not structuring the else if statement they way I intend it to work.