1$(document).ready(function(){ 2 3 if($("ul.dropdown").length) { 4 $("ul.dropdown li").dropdown(); 5 } 6 7}); 8 9$.fn.dropdown = function() { 10 11 return this.each(function() { 12 13 $(this).hover(function(){ 14 $(this).addClass("hover"); 15 $('> .dir',this).addClass("open"); 16 $('ul:first',this).css('visibility', 'visible'); 17 },function(){ 18 $(this).removeClass("hover"); 19 $('.open',this).removeClass("open"); 20 $('ul:first',this).css('visibility', 'hidden'); 21 }); 22 23 }); 24 25}