$(function () { setNavHeight() function setNavHeight() { let mobile_nav_content_height = 0; if($('#mobile_nav .panel-menu-mobile .only-ul-show').length === 0) { $('#mobile_nav .panel-menu-mobile>.only-warp>.panel-menu-ul>li').each((index, ele) => { mobile_nav_content_height += ele.clientHeight; }); }else { $('#mobile_nav .panel-menu-mobile .only-ul-show:last>li').each((index, ele) => { mobile_nav_content_height += ele.clientHeight; }); } $('#mobile_nav .mobile_nav_content .panel-menu-mobile').height(mobile_nav_content_height); } // Mobile terminal menu switch let setp = 0; let onlyWarpDOM = $('.only-warp'); let onlyMenuDOM = $('.only-warp-menu'); $('.only-ul-li').click(function (e) { let href = $(this).find('a').attr('href'); if (href !== 'javascript:void(0)' && $(e.target).closest('a').length > 0){ e.stopPropagation(); return; } e.stopPropagation(); let onlyWarpWidth = onlyWarpDOM.width(); if ($(this).children('.panel-menu-ul').length) { setp++; onlyMenuDOM.css({ left: -onlyWarpWidth * setp, }); $(this).children('.panel-menu-ul').addClass('only-ul-show'); setNavHeight(); onlyWarpDOM.scrollTop(0); } }); $('.panel-menu-parent').click(function (e) { e.stopPropagation(); let onlyWarpWidth = onlyWarpDOM.width(); setp--; $(this).parent().removeClass('only-ul-show'); onlyMenuDOM.css({ left: -onlyWarpWidth * setp, }); setNavHeight() }); });