$(function(){ clickshow5("#jhjt",".jhjt",".kefu",".but2",".white_content3","se"); clickshow5("#white_content3",".white_content3",".kefu",".btn3",".jhjt","se"); tabshow(".zz_top_lii",".showj_r","hover"); tabshow(".zz_top_li",".zz_info","hover"); mapshow(".map_style a"); DownShow("#Map area",".area_city",""); }); function tabshow(obj1,obj2,cl) { var id; $(obj1).mouseover(function(){ id=$(obj1).index($(this)); $(obj1).removeClass(cl); $(this).addClass(cl); $(obj2).hide(); $(obj2).eq(id).show(); }) $(obj2+":first").show(); } function mapshow(obj1) { //var id; $(obj1).hover(function () { $(this).parent().find("span").show(); }, function () { $(this).parent().find("span").hide(); }) } function clickshow5(obj1,obj2,obj3,obj4,obj5,cl){ //点击按钮收展 $(obj1).parent().removeClass(cl); $(obj1).on('click',function(e){ e.stopPropagation(); $(this).parent().addClass(cl).siblings().removeClass(cl); $(obj2).show(); $(obj3).hide(); $(obj5).hide(); }); $(obj4).click(function(){ $(obj1).parent().removeClass(cl); $(obj2).hide(); }); $(obj1).parent().removeClass(cl); $(obj2).hide(); //层外点击关闭 $(document).bind("click",function(e){ var target = $(e.target); if(target.closest(obj2).length == 0){ $(obj1).parent().removeClass(cl); $(obj2).hide(); } }) } function DownShow(obj1,obj2,cl){ var index,id,timer,divcreate; divcreate=false; $(obj1).hover( function(){ id=$(obj1).index(this); $(obj1).removeClass(cl); $(this).addClass(cl); hidecur(); $(obj2).eq(id).stop(true,true).delay(500).slideDown(100, function(){}); divcreate=true; index=id; },function(){ id=$(obj1).index(this); divcreate=false; hidecur(); $(obj1).removeClass(cl); }) $(obj2).hover( function(){divcreate=true;hidecur();},function(){id=$(obj2).index(this);divcreate=false;hidecur();}); function hidecur(){ clearTimeout(timer); if(index!=id){$(obj2).eq(index).stop(true,true).delay(50).fadeOut("fast", function(){}); } timer=setTimeout(function(){ if(!divcreate){ $(obj2).eq(id).stop(true,true).delay(50).fadeOut("fast", function(){}); }; },100); } }