when we click over menu category menu items are hide but some of the element of subcategory are still visible we have to hide them too.
function open_cat(objid,sender) { $(".pct").css( "display", "block" ); $(".category_menu").removeClass( "its_selected" ); $(sender).addClass( "its_selected" ); $(".pcc").css( "display", "none" ); $("#"+objid).css( "display", "block" ); var main=0; var pos = $("#"+objid).position(); var postion = main+pos.top; // $('html, body').animate({scrollTop:postion}, 'slow'); $('body,html').animate({ scrollTop: $("#menu2").position().top }, 1); } function launchsubmenu(objid) { $(".pcc").css( "display", "none" ); $(".pct").css( "display", "none" ); $("#pcat_"+objid).parent().css( "display", "block" ); $("#pcat_"+objid).css( "display", "block" ); $('body,html').animate({ scrollTop: $("#menu2").position().top },1); }