CtxMenu-Javascript
CtxMenu-Javascript copied to clipboard
How to get the clicked element
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!
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!