$(function(){ $p_obj = $(".sub-menu > li[class='active'] > a"); if ($p_obj) { var v = $p_obj.attr("href"); if (v != "#") { $p_obj.parent().children("ul").show(); } } $ac_obj = $(".sub-menu li li[class='active']"); if ($ac_obj) { $pac_obj = $ac_obj.parent().parent(); $pac_obj.addclass("active"); $pac_obj.children("ul").show(); } $(".sub-menu > li > a").bind("click",function(e){ var v = $(this).attr("href"); if ($(this).parent().has("ul").length && v == "#") { e.preventdefault(); $(".sub-menu ul").slideup(); var t = $(this).parent().children('ul'); if ($(this).parent().attr("class")=="active") { t.parent().parent().children("li.active").removeclass("active"); }else { t.parent().parent().children("li.active").removeclass("active"); t.parent().addclass("active"); t.slidedown(); } } }); $(".subcon").eq(0).show(); $(".contab li").eq(0).find("a").addclass("cur"); $(".contab li").click(function(){ var index = $(this).index(); $(".subcon").hide(); $(".subcon").eq(index).show(); $(".contab li a.cur").removeclass("cur"); $(this).find("a").addclass("cur"); return false; }); });