0

I have this code in react 17.0.2, and I hope that when I hover over a section, the onMouseOver function that I pass to the component by props is executed.

This function just prints a console.log of the e.target.

When I hover over the section, I correctly see on console <section id="amenities"... />, but if I hover over any inner element of this section, the inner element is now consoled. Is there a way to ALWAYS get as e.target the parent section element instead of its inner elements?

<section
  className="resort-amenities"
  id="amenities"
  onMouseEnter={onMouseOver}
 >
  <h2 className="title">Amenities</h2>
  <div className="amenities-wrapper">
    {renderAmenities}
  </div>
</section>

cont onMouseOver = () => console.log(e.target) 
Agustin G.
  • 72
  • 3
  • 19
  • 2
    Does this answer your question? [What is the exact difference between currentTarget property and target property in JavaScript](https://stackoverflow.com/questions/10086427/what-is-the-exact-difference-between-currenttarget-property-and-target-property) – sergdenisov Aug 02 '22 at 14:12
  • 1
    thanks a lot, i was trying with target and relatedTarget. This comment solve my problem! – Agustin G. Aug 02 '22 at 14:25

0 Answers0