Last active
May 31, 2023 18:39
-
-
Save oguzhancvdr/f1957b73f4d149d0720f404977be2d4a to your computer and use it in GitHub Desktop.
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
// Traverse up the DOM tree to find an element with data-place-id attribute | |
let targetElement = e.target; | |
while (targetElement && !targetElement.dataset.placeId) { | |
targetElement = targetElement.parentElement; | |
} | |
// Retrieve the data-place-id attribute value | |
const placeId = targetElement ? targetElement.dataset.placeId : undefined; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find closest element with data-place-id attribute