Prevent code execution when clicking anchor menu

Hello,

I managed to code scrolling by page. I’m facing an issue when clicking the anchor menu. How can I prevent executing my code when the user clicks the anchor menu bar?