I assume it has something to do with a quirk in our HTML because other places on the same page work just fine.
The only way I was able to solve this problem was to do:
if($('#element_id').css('display') == 'none')
{
// Take element is hidden action
}
else
{
// Take element is visible action
}