简体   繁体   English

d3 SVG线元素未触发onclick事件

[英]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. 我尝试使用edges.on('click',function(){console.log('line click');})触发click事件。 but it is not work at all. 但这根本没有用。 Even I use jquery to do the onclick event it still not work. 即使我使用jquery来执行onclick事件,它仍然无法正常工作。 All the ways are not work, what happen in my code? 所有方法都不起作用,我的代码会发生什么? Thank you very much. 非常感谢你。

Original javascript style to do onclick event: 执行onclick事件的原始JavaScript样式:

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

Jquery style to do onclick event: jQuery样式做onclick事件:

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

D3 style to do onclick event: D3样式做onclick事件:

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

Remove this: 删除此:

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

If you use none for the pointer events: 如果不使用none指针事件:

The element is never the target of mouse events; 元素永远不是鼠标事件的目标;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM