【问题标题】:d3.js - image `mouseenter` stopPropagation throw errord3.js - 图像`mouseenter` stopPropagation 抛出错误
【发布时间】:2015-05-24 06:05:03
【问题描述】:

我有一个小组。该组包含textarcimage。在mouseenter 上,我想将stropPropagation 添加到活动中。 (因为每次鼠标点击文本事件都会触发。)

所以我添加了d3.event.sourceEvent.stopPropagation(); 方法。但它会抛出错误 Uncaught TypeError: Cannot read property 'stopPropagation' of undefined 这里有什么问题?

代码:

d3.selectAll('.subAppGroupDetail image')
    .on('mouseenter', function (e) {
        d3.event.sourceEvent.stopPropagation();
        $('.quickView').show(500);
    })
    .on('mouseleave', function (e) {
    d3.event.sourceEvent.stopPropagation();
    $('.quickView').hide(100);
})

【问题讨论】:

    标签: javascript jquery d3.js


    【解决方案1】:

    使用这样的代码:

      d3.selectAll('.subAppGroupDetail image')
       .on('mouseover', function (e) {
                    d3.event.stopPropagation();
                    $('.quickView').show(500);
       })
      .on('mouseout', function (e) {
               d3.event.stopPropagation();
               $('.quickView').hide(100);
      })
    

    【讨论】:

      猜你喜欢
      • 2018-09-24
      • 2018-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-15
      • 1970-01-01
      • 2021-07-03
      • 1970-01-01
      相关资源
      最近更新 更多