Skip to content

Snippets / JS

JS

Hide Menu Popup When Clicking Anchor Navigation

D Donald McGuinn · 136 views · Updated 1 year ago
When doing a single page site, I noticed that that menu popup doesn't hide after clicking the anchor nav item. This code fixes that.
document.addEventListener('click', function(event) {
if (event.target.closest('.ts-popup-root .ts-field-popup li a')) {
const popup = document.querySelector('.ts-popup-root');
if (popup) {
popup.style.display = 'none';
}
}
});
JS · 8 lines

Discussion

Ask a question or share how you used this.

Log in to join the discussion.

No comments yet — be the first.

Voxel Guide assistant
Ask about snippets, addons & how-tos

Hey — how can I help?

I can dig through the library for snippets, addons, and tutorials.

AI can be wrong — double-check anything important.