N
N
newaitix2015-09-20 13:45:30
JavaScript
newaitix, 2015-09-20 13:45:30

Why does onmouseout work?

Suppose there is one block and two nested in it

<div id="a">
<div id="b"></div>
<div id="c"></div>
...
</div>

if i write:
document.getElementById('a').onmouseout=function(){console.log("Курсор покинул элемент 'a'");};

Then it will fire both when the cursor leaves the 'a' element and when it leaves the other two elements 'b' and 'c' but remains within the 'a' element.
How can I change the code so that the event fires only on the 'a' element

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Halyluya, 2015-09-20
@halyluya

I'll just leave it here :)
https://learn.javascript.ru/event-bubbling

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question