MouseEnter and MouseLeave VS. MouseOver and MouseOut

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ม.ค. 2025

ความคิดเห็น • 18

  • @Jeff-2112
    @Jeff-2112 6 ปีที่แล้ว +3

    It would be great to hear some real world possible uses or situations where the extra calls from mouseover/mouseout would be useful compared to the enter/leave method. This entire JS Events playlist has been great so far!

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  6 ปีที่แล้ว +4

      Flyout menus is probably the most common use for enter/leave. If you have an anchor that you mouse over to show a new menu, when you mouse over the new menu you don't want a mouseout event to fire on the original anchor because that would make the new menu disappear. In the HTML you would structure your menu like this:
      Menu Item 1
      Sub Item 1
      Sub Item 2
      Menu Item 2
      The first menu item contains an anchor PLUS an inner UL that holds the flyout menu. We could add a the mouse enter/leave event to the li element.

    • @qzbnyv
      @qzbnyv 4 ปีที่แล้ว +2

      @@SteveGriffith-Prof3ssorSt3v3 Hi! I think the comment above was specifically asking for when you would actually want to use mouseover/mouseout (...with its extra calls) instead of mouseenter/mouseleave (...which you gave them an example of).
      I had the same question as OP, wondering if we should use enter/leave 100% of the time or whether there was actually a use case for over/out (despite being less efficient).
      Great video as always. Loving the JavaScript Events playlist. :)

  • @SupraStututututu
    @SupraStututututu 5 ปีที่แล้ว +1

    Excellent video, thank you a lot. You helped me so much with my project on my job.
    Respect you, man!

  • @fadilnatakusumah195
    @fadilnatakusumah195 2 ปีที่แล้ว

    Hi, just watching your video because I have task dealing with this (lol). You know the weird thing is if you hover slowly from the left side of the element that has mouse Enter and mouseLeave, the mouseLeave will triggered immediately, but when we hover from top/right/bottom, it will not triggered the mouseLeave unless we leave the element. it's so weird

  • @coralmusicaviva
    @coralmusicaviva 6 ปีที่แล้ว

    Thanks Steve, great video and lesson, I will follow your videos.

  • @nixes1636
    @nixes1636 9 หลายเดือนก่อน

    I really like your videos. Currently on video 7/29 in the playlist. I was wondering if all 4 mouse events have property useCapture so they can be changed to act in either of the bubbling or capture way? So MouseEnter could be made to act as MouseOver by setting useCapture to true. I'm still a little confused about bubbling.

  • @ga7853
    @ga7853 5 ปีที่แล้ว +1

    Only one question, why i did not find your videos a long time ago?

  • @dancruz7845
    @dancruz7845 6 ปีที่แล้ว +1

    Thanks that was interesting... I've only been coding for a few months but Im wondering when would you decide to use Javascript for this kind of functionality vs using CSS :hover and how do they compare? Thanks!

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  6 ปีที่แล้ว +1

      The CSS :hover is only for changing the appearance. Javascript let's you do anything to the page, even change the content.

  • @yargy
    @yargy 7 ปีที่แล้ว

    you are really great at explaining stuff

  • @hussamkhatib746
    @hussamkhatib746 4 ปีที่แล้ว

    great content . can you tell me what are bubbling?

  • @yadusolparterre
    @yadusolparterre 3 ปีที่แล้ว

    Why did you create the four paragraphs?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  3 ปีที่แล้ว

      There are six paragraphs. They are there so the techniques can be demonstrated in a realistic environment.

  • @VivenVatsal
    @VivenVatsal 3 ปีที่แล้ว

    Thank you very much.