mootools 鼠标事件目标
就mootools鼠标事件而言,“目标”、“相关目标”和“fromelement”之间有什么区别?
例如,在下面的代码中为什么没有使用 target 以及为什么有 ||涉及?
'mouseenter':function(e){
var reltar = e.relatedTarget || e.fromElement;
}
whats is the difference between a "target" a "relatedTarget" and a "fromelement" in terms of a mootools mouse event?
for example in the following code why is target not being used and why is there a || involved?
'mouseenter':function(e){
var reltar = e.relatedTarget || e.fromElement;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,
目标
是事件正在分派的元素。即latedTarget
是鼠标悬停/输入时鼠标来自的元素。fromelement
是 MS 实现latedTarget
功能的方法。因此,是一种跨浏览器的方式来检测鼠标来自哪个元素。
Basically,
The
target
is the element the event is dispatching on. i.e.The
relatedTarget
is the element the mouse came from in case of mouseover/enter.fromelement
is the MS way to implement whatrelatedTarget
does. Therefore,is a cross-browser way to detect what element the mouse came from.
W3C 规定
event.latedTarget
是mouseover
事件中鼠标来自的元素,或者是鼠标在mouseout
事件中转到。但是,IE 对于这两种情况使用两个单独的属性:
event.fromElement
是mouseover< 中鼠标来自的元素/code> 事件,而
event.toElement
是鼠标在mouseout
事件中转到的元素。您可以在 Peter-Paul Koch 的以下页面上找到更多详细信息和一些示例(那里有非常好的内容):
http://www.quirksmode.org/js/events_mouse.html
W3C says that
event.relatedTarget
is the element where mouse comes from in amouseover
event, or the element that the mouse goes to in amouseout
event.However, IE uses two separate properties for those two cases:
event.fromElement
is the element the mouse comes from in amouseover
event, whileevent.toElement
is the element the mouse goes to in amouseout
event.You can find more details and some examples on the following page by Peter-Paul Koch (very good content there):
http://www.quirksmode.org/js/events_mouse.html