// Check whether links are external: // (Only works with elements that have href): $.extend($.expr[':'],{ external: function(a,i,m) { if(!a.href) {return false;} return a.hostname && a.hostname !== window.location.hostname; } }); $(function() { $(".menu li a").bind("click",function() { if($(this).parent().find("a").size() > 1 ){ $(this).parent().parent().find("li ul:visible").not($(this).parent().find("ul:first")).slideToggle(500,function(){ $(this).parent().find("a.expanded").removeClass('expanded'); }); $(this).addClass('expanded'); $(this).parent().find("ul:first").slideToggle(500,function(){ if($(this).parent().find("ul").css('display') == 'none') { $(this).parent().find("a.expanded").removeClass('expanded'); } }); return false; } }); });