Jacky Shek Jacky Shek - 5 months ago 96
Javascript Question

d3 SVG Line elements not firing onclick event

I have tried to use

edges.on('click',function(){console.log('line click');})

to firing the click event. but it is not work at all. Even I use jquery to do the onclick event it still not work. All the ways are not work, what happen in my code? Thank you very much.

Original javascript style to do onclick event:


Jquery style to do onclick event:


D3 style to do onclick event:



Remove this:

.style("pointer-events", "none")

If you use none for the pointer events:

The element is never the target of mouse events;

Check the documentation: https://developer.mozilla.org/en/docs/Web/CSS/pointer-events