Is there a way to change the CSS of a parent div only if the child is visible? And back again when not??? I've been racking my brains and I'm all Googled and jQuery documentationed out.
4 Answers
$(".childClass").each(function(){
if($(this).is(":visible"))
{
$(this).parent().css("some_attribute", "some_value");
}
else
{
$(this).parent().css("some_attribute", "default_value");
}
});
You can also use addClass/RemoveClass on the parent, but be careful if you remove a class that you're using as part of the selector to find the child element.