I am using this type of menu as in link : https://github.com/SuperZombi/SwipeMenu_JS/blob/main/examples/swipe_menu.html. when i scroll down the main menu submenu slides out and overlaps the main menu.Here the submenu height remains same as main menu height and if there are few submenus i have to scroll up to view the top of submenus. When there are many main menus the scroll remains at same position when submenus displays. How can i achieve submenu auto scroll to top when a menu is clicked? I tried like this
<script>
var myMenu = document.getElementById("myMenu");
$('#myMenu').click(function (e) {
$('body').animate({
scrollTop: $('#myMenu').offset().top - 20
}, 2000);
});
</script>
Its not working.