Jorus Jorus - 2 months ago 10x
CSS Question

Scroll to top after click

When i open my menu and scroll it downwards, close it and reopen it again, the menu stays at that point, but i want it to be opened at top everytime you open it also with an anchor link.

I've added this to close the menu when clicking the link:

$("li > a").on("click", function() {

Everything works fine, except that its not going to top after re-opening.

I tried:


But this had no effect. The only thing that worked so far was:


But I think it's overkill to reload the page every time.

Is there a way to close the menu and return the menu to top after re-opening, on click?

This all has to do with this topic,

Turn blivesta animsition menu into off canvas (push body) menu

but because it's a separate question i thought it would be better to start a new topic.

Edit: Let me be more specific about the situation.
I open my menu by clicking the hamburger icon. The list is scrollable so when i go down a bit, click the anchor link, the menu closes and i'm at my anchor point. So far so good.
When i reopen the menu, it's still at the point in my menu, where i was scrolling to. But i want to be on top of the menu again after re-opening, without refreshing my page.


You need to translate to 0px:

$("li > a").on("click", function() {
    $(".drawer-menu").css("transform","translate(0, 0) translateZ(0)");