我尝试过检查 DOM 等,但不确定为什么将“.tooltip”附加到处理程序中。如果删除它不会产生任何影响,并且似乎没有重大值(value):
g.selectAll("circle")
//
//why is .tooltip appended here?
//
.on("mouseover.tooltip", function(d) {
d3.select("text#" + d.line_id).remove();
d3.select("#chart")
.append("text")
.text(d.late_percent + "%")
.attr("x", time_scale(d.time) + 10)
.attr("y", percent_scale(d.late_percent) - 10)
.attr("id", d.line_id);
});
非常感谢任何澄清。
最佳答案
这是一个命名空间
http://docs.jquery.com/Namespaced_Events
"jQuery provides a concept called namespaced events: Simply add a classname to your event when you declare it. You can then reference that namespaced event both with unbind and trigger."
$('.class').bind('click.namespace', function(){});
$('.class').trigger('click.namespace');
$('.class').unbind('click.namespace');
关于javascript - 这个事件处理程序在做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12694830/