Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active December 21, 2022 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/d40d920d5ddb1885a51bb1fa0bb9000b to your computer and use it in GitHub Desktop.
Save wplit/d40d920d5ddb1885a51bb1fa0bb9000b to your computer and use it in GitHub Desktop.
multiple buttons to open gallery
<script>
document.addEventListener("DOMContentLoaded", () => {
const buttons = document.querySelectorAll(".graphic_gallery");
buttons.forEach((button) => {
const prevSibling = button.previousElementSibling;
const firstItem = prevSibling.querySelector(".bricks-lightbox");
button.addEventListener("click", (event) => {
event.preventDefault();
firstItem.click();
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment