Side Navigation With Sub-Link[Custom-Code]{Review!?}

Hello All,
I’ve written a jQuery code to display sub-link when the main link is clicked. I have debugged the logic it should work fine but there is a glitch any webflow experts can look into this and help.

Problem: The pseudo-code.If “PAGE 5” is active then “PAGE 5A” is visible and the user can click on it. If “PAGE 5A” is active and the user wants to check “PAGE 5” then also “PAGE 5A” should be visible not reload to be active again.

Here is the Loom link Problem Explained here


Published Link

@samliew @webdev @sabanna @PixelGeek @vincent can anyone help me achieve this :peace_symbol:

Thanks in advance,

Here is my site Read-Only: LINK
(how to share your site Read-Only link)