My webpage includes two SVG images inserted using D3.js. I am able to add click events to the SVGs that are directly appended to the body. However, I have encountered an issue with another "floating" div positioned above the first SVG, where I append a different SVG. When attempting to add click events to this setup, they do not trigger.
I also experimented with tracking mouse positions, but this only worked for the SVG appended to the body as well.
Is there a method to assign click listeners to the rect
elements inside the "floating" div?
You can view the fiddle here: JsFiddle
The challenge is to toggle the color between black and white when clicking on a rect
element at the top of the page. How can this be achieved?
I also attempted to use jQuery for a solution...
It's worth noting that hovering over the second SVG allows you to drag and zoom in on the first one, which is not the desired behavior.