Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

How to get the clicked element #5

Open
TheWilley opened this issue Aug 17, 2022 · 1 comment
Open

How to get the clicked element #5

TheWilley opened this issue Aug 17, 2022 · 1 comment

Comments

@TheWilley
Copy link

Please correct me if I'm wrong, but the documentation mentions no way get the element that was clicked on. There is, however, a way to get it.

contextMenu.addItem("alertElement", function () {
    alert(contextMenu._elementClicked)
});

I assume the _elementClicked variable is not supposed to be accessed, as it's marked as private. Still, I thought it could be worth mentioning!

@nils-soderman
Copy link
Owner

Hi,

The first argument passed into the function will be the clicked element:

contextMenu.addItem("alertElement", function (clickedElement) {
    alert(clickedElement)
});

You can see an example of this with the ChangeElementColor function in the example page source.

But yes, I should definitely mention that somewhere in the documentation, thanks for letting me know!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants