Javascript 为什么赢了';我的d3 html div工具提示是否隐藏在鼠标外?

Javascript 为什么赢了';我的d3 html div工具提示是否隐藏在鼠标外?,javascript,html,css,d3.js,Javascript,Html,Css,D3.js,因此,我在myview.haml中定义了html工具提示: 无论什么 哪个有下面的风格 #工具提示{ 位置:绝对位置; 有些人在这里; 指针事件:无; } #tooltip.hidden{ 显示:无; } 我的html div工具提示在鼠标上方显示(coffeescript): msBarTextLabels.on(“鼠标悬停”(d)-> xPosition=svgContainer.offsetLeft yPosition=svgContainer.offsetTop d3.选择(“工具

因此,我在myview.haml中定义了html工具提示:


无论什么
哪个有下面的风格

#工具提示{
位置:绝对位置;
有些人在这里;
指针事件:无;
}
#tooltip.hidden{
显示:无;
}
我的html div工具提示在鼠标上方显示(coffeescript):

msBarTextLabels.on(“鼠标悬停”(d)->
xPosition=svgContainer.offsetLeft
yPosition=svgContainer.offsetTop
d3.选择(“工具提示”)
.选择(“#值”)
.html(('charge:'+d.charge+'
强度:'+d.m_强度) d3.选择(“#工具提示”).classed(“隐藏”,false) ) msBarTextLabels.on(“mouseout”,d3.select(“工具提示”).classed(“hidden”,true))
因此,工具提示使用正确的数据和所有信息在鼠标上方正确取消隐藏,但不会在鼠标上隐藏

有没有关于为什么会发生这种情况的线索


感谢@Lars所说的,您实际上并没有将回调函数传递给
mouseout
处理程序。相反,它实际上是在执行
d3.select(“工具提示”).classed(“hidden”,true)
并传递结果(d3选择)。更改为:

msBarTextLabels.on("mouseout", (d) ->
    d3.select("#tooltip").classed("hidden", true)
)

我不是Coffeescript方面的专家,但在第二种情况下,似乎您实际上没有定义要调用的函数,而是只调用一次的代码。可能类似于
()->d3。选择…
?这完全起到了作用。让人尴尬的是,这件事多么明显。