阅读背景:

使用addEventListener和按钮中的嵌套元素的事件委派模式

来源:互联网 

I have a set of buttons in a parent. Each containing an SVG icon which are added programmatically. I'm attempting to listen on the parent element and then use event delegation to trigger different functionality for particular buttons, but what lands up happening is I get event targets of the contained svg's or paths rather than the buttons themselves. Is there a way to leverage event bubbling, or change the way I'm doing this to still avoid adding a ton of event handlers, and trigger the events I need? Heres some simplified code:I have a set of buttons in a parent. Each conta




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: