<div onmouseover="d_a()" onmouseout="d_b()">When the mouse is moved from outside the DIV to the first line, d_a and p_a are called as expected. When the mouse moves from Line 1 to Line 2, p_b (expected), as well as p_a (highly unexpected) are called even though the mouse has not left the DIV. p_a is called due to event bubbling; the mouseover event bubbles from its target through all the target's ancestors toward the document object.
<p onmouseover="p_a()" onmouseout="p_b()">Line 1</p>
<p>Line 2</p>
</div>
Probably the best workaround is to compare the event target (browser-dependent, use xEvent to get browser-independent code) with the current element.
No comments:
Post a Comment