Difference between e.target and e.currentTarget

后端 未结 10 905
谎友^
谎友^ 2020-11-22 06:29

I don\'t understand the difference, they both seem the same but I guess they are not.

Any examples of when to use one or the other would be appreciated.

10条回答
  •  孤街浪徒
    2020-11-22 06:36

    e.currentTarget is always the element the event is actually bound do. e.target is the element the event originated from, so e.target could be a child of e.currentTarget, or e.target could be === e.currentTarget, depending on how your markup is structured.

提交回复
热议问题