Created
June 28, 2026 01:07
-
-
Save wplit/ddabc0e1be132130535168f3aed00b43 to your computer and use it in GitHub Desktop.
click hotspot marker when link is clicked/hovered
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener('DOMContentLoaded', function() { | |
| const links = document.querySelectorAll('.my-link'); | |
| const popoverButtons = document.querySelectorAll('#%%ELEMENT_ID%% .oxy-popover_marker'); | |
| links.forEach((link, index) => { | |
| const correspondingButton = popoverButtons[index]; | |
| if (correspondingButton) { | |
| // Click handler | |
| link.addEventListener('click', function(e) { | |
| e.preventDefault(); | |
| correspondingButton.click(); | |
| }); | |
| // Hover handler | |
| link.addEventListener('mouseenter', function() { | |
| correspondingButton.click(); | |
| }); | |
| // Mouse leave handler - close the popover | |
| link.addEventListener('mouseleave', function() { | |
| // Click again to close | |
| if (correspondingButton.getAttribute('aria-expanded') === 'true') { | |
| correspondingButton.click(); | |
| } | |
| }); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment