A little late, but have you checked the actual value of event.target
and verified it is the element that you are expecting? The way I handle this is by applying an id to each of the div's you are returning from your subs.map
, then in the onMouseLeave
function you will check if(e.target.id === expectedID)
before running the code.
This prevents the duplicate styling, but doesn't solve the problem of: now your code didn't run on the expected element. I haven't found a good solution for this yet besides replacing the e.target
with document.getElementById