我想创建一个 Highcharts 图表,整个 div
都有一个 onclick
函数,但我不希望导出按钮处理点击事件。它应该像普通的导出按钮一样 react 。
我尝试了一些 jQuery 技巧来避免它,通过获取 Highcharts Buttons 类:highcharts-button
,但它不起作用:
jQuery("#container").on('click', ':not(.highcharts-button, .highcharts-button *)', function(e){
e.stopPropagation();
alert('CLICK');
});
这是我的 JSFiddle 。 (问题是:我不想在单击“导出”按钮时看到弹出警报)。
最佳答案
一种方法是过滤事件目标,例如:
jQuery("#container").on('click', function(e){
if ($(e.target).closest('.highcharts-button, .highcharts-contextmenu').length) return;
e.stopPropagation();
alert('CLICK');
});
-jsFiddle-
关于jquery - 使 div 容器可点击,导出按钮除外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31293835/