A
A
AndRussia2020-06-24 13:56:35
JavaScript
AndRussia, 2020-06-24 13:56:35

How to make a clickable canvas?

Hello. I've been trying to figure out how to make a clickable canvas for about an hour now, but I can't. The bottom line is this: I click on the circle and I have a hidden div with content. Maybe there is some documentation or something like that. Thanks in advance.

I didn't really understand how to work with CustomEvent

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Robur, 2020-06-24
@Robur

canvas.addEventListener('click', function() { })
Naturally, the mouse knows nothing about the circles that you drew on your canvas, or you calculate it yourself, or use svg where the circle is a separate element and you can hang your click handler on it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question