The difference between target and currenttarget of event in JS

Source: Internet
Author: User

Today again encountered this problem, always do not know the difference between target and Currenttarget, Baidu search time to see the article explained very clearly, deliberately recorded under the record, in case of a rainy day:

What is the difference between target and currenttarget?

Plain and easy to say:
For example, there's A and B now,
A.addchild (B)
A monitor mouse click events
So when you click on B, Target is B,currenttarget is a
In other words, currenttarget is always the listener, and Target is the true issuer of the event.


Summarize:
Target in the phase of the event flow, the capture, the target, and the bubbling phase of the currenttarget. The two points are the same only when the event flow is at the target stage, and when in the capture and bubbling phase, target points to the object being clicked and Currenttarget to the object that is the current event activity (usually the parent).

The difference between target and currenttarget of event in JS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.