www.gusucode.com > 一款纯正的仿京东、淘宝购物网站左侧分类菜单源码程序 > 一款纯正的仿京东、淘宝购物网站左侧分类菜单/jqueryleftmenu/jqueryleftmenu/js/3c-menu.js

    $(document).ready(function(){
	$( ".J_MenuItem" ).each( function( index ){
		$( this ).mouseover( function(){
			
			var catTop,
				borderTop = $( this ).offset().top - 3,
				viewHeight = $( window ).height(),
				scrollTop = $( document ).scrollTop(),
				relaxHeight = viewHeight - ( borderTop - scrollTop );
			
			$( ".border" ).css( "top", borderTop ).show();
			$( ".cat-subcategory" ).show();
			$( ".shadow div" ).hide().eq( index ).show();
			
			var catHeight = $( ".cat-subcategory" ).height();
			if( catHeight <= relaxHeight ){
				catTop = borderTop;
			}else if( catHeight > relaxHeight && catHeight < viewHeight ){
				catTop = scrollTop + viewHeight - catHeight - 10;
			}else{
				catTop = scrollTop + 5;
			}
			$( ".cat-subcategory" ).css( "top", catTop );
			
			$( "span" ).show();
			$( this ).find( "span" ).hide();
		});

		$( ".mallCategory" ).mouseleave( function(){
			$( ".cat-subcategory" ).hide();
			$( ".border" ).hide();
			$( "span" ).show();
		});

	});
});