Through CSS I set all divs to visibility :hidden. By clicking the item in the navbar I want the target div to be set to visibility :visible. This works just fine but I want to avoid setting it again if it is already visible.
This code doesn't work
function showNewElement(actID) {
ID = actID.substring(1, actID.length);
$('.mainDiv:visible').css("visibility", "hidden");
$("#" + ID + ':hidden').css("visibility", "visible").hide().fadeIn('fast');
}
So I had to wrap it in an if-Statement
function showNewElement(actID) {
var ID = actID.substring(1, actID.length);
if ($("#" + ID).css("visibility") != "visible") {
$('.mainDiv').css("visibility", "hidden");
$("#" + ID).css("visibility", "visible").hide().fadeIn('fast');
}
}
Why does it not work the other way?