Query DOM element relative to the Button

Hi! I created a button that appears in multiple places on the same page.

When the button is clicked, I want to query its ancestor DOM element using jQuery Selector Reader brick. The problem is, I don’t seem to have any way of knowing which one of my buttons was clicked.

How do I determine the exact element/path to the element of the clicked button?

Hi Valor, welcome to the PixieBrix community forums!

Currently, there’s no way to get the context (ancestor DOM element) of which button you have clicked.
You can use the “insert HTML element” to insert a button with a unique ID, then you can use the Trigger brick (on click event) to perform an action when that button with the unique ID has been pressed, however you won’t be able to easily retrieve the ancestor DOM element.

Perhaps you can try to read the whole HTML of the page and use Regex to capture the ancestor DOM element, but it won’t be super immediate to get.

Great feedback however, I will add it to our list of things to add to the Page Editor.

Thank you!