TransitionEnd listener firing on child elements

前端 未结 2 1646
谎友^
谎友^ 2021-02-20 07:35

I added a transitionend event listener to a div. This div has children who have transition on some elements. I want the transitionend even

2条回答
  •  半阙折子戏
    2021-02-20 08:30

    Events are bubbling by default, meaning that they will be "transmitted" to the parent element until they hit the body or a handler that will stop them.

    You can either :

    • Filter by the event's target being sure it's the element you're targetting.
    • Listening to the event on children and event.stopPropagation() on them. That way, they won't bubble through the parent anymore.

    If you'd show us some code, it would be easier to help you, depending on your current implementation.

提交回复
热议问题