Languages

JavaScript - onclick event doesn't work on custom context menu items

0 points
Asked by:
Wiktor-Sribiew
830

Hi, I've tried to make a custom context menu using JavaScript and I have got a problem with the click event.

I've added console.log() to each item inside my context menu to be executed on click event but it doesn't work and I don't know why. Can you help me with this?

Here's my code:

1 answer
0 points
Answered by:
Admin Dirask Community
4380

It seems like the context-menu is closing before you click on the item because of the mousedown event added to the document. Change the mousedown to the mouseup event and it works fine.

0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join