Jacky Shek Jacky Shek - 1 month ago 19
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:

https://jsfiddle.net/q21c186r/4/

Jquery style to do onclick event:

https://jsfiddle.net/q21c186r/3/

D3 style to do onclick event:

https://jsfiddle.net/q21c186r/5/

Answer

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

Comments