开发者

How can I find the element that fired a mouseout event in JS Prototype?

When you have a mouseover observer on an element "parent" and the event gets fired by the element "child" which is a child of "parent", event.element() returns the child. But when you have a mouseout observer on an element and it gets fired from a child element, event.element() returns only the parent.

I really need to know whether the mouseout event got fired by th开发者_开发百科e parent or child, how can I do this?


Inside the event handler function, you can try to get back the parent if you know that some css selector applies to it or its id by using the "up" method like this :

function eventHandler(e) {

  var parentElement;

 // I remember doing something like this, but not 100% its exactly what works

  parentElement = e.element().up('some css selector to find parent') || e.element();

  // do whatever you want with parentElement

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜