Try this:
$('#nav > li').each(function(){
if($(this).find('a').hasClass('active')){
$(this).find('ul').slideDown();
}
});
or
$('#nav > li > a').each(function(){
if($(this).hasClass('active')){
$(this).parent().find('ul').slideDown();
}
});
Instead of this
$('#nav > li > a').ready(function(){
if ($(this).attr('class') == 'active'){
//your code here
}
});