Skip to content

Instantly share code, notes, and snippets.

@wplit
Created June 28, 2026 01:07
Show Gist options
  • Select an option

  • Save wplit/ddabc0e1be132130535168f3aed00b43 to your computer and use it in GitHub Desktop.

Select an option

Save wplit/ddabc0e1be132130535168f3aed00b43 to your computer and use it in GitHub Desktop.
click hotspot marker when link is clicked/hovered
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