The following code was given as an example to illustrate the difference between event.target and event.currentTarget but it's not clear to me. If someone can help with this, it will be great help to me.
It's an example code in jsfiddle :
The following code was given as an example to illustrate the difference between event.target and event.currentTarget but it's not clear to me. If someone can help with this, it will be great help to me.
It's an example code in jsfiddle :
You need to look up more about bubbling and event capturing. When you click on an element in the DOM that "click"event starts to be called from that element all the way up to the root document, "notifying" all the elements in the series that something was clicked inside you, you might want to do something with it! I wont mind-blow you by saying that at the end the event is propagated back to the first element again, going through the same series of elements in reversed order, look up more stuff about it.
Essentially the difference is that when the event is raised each callback get a copy of "the original element that actually trigger the click, the inner most element under the user's cursor at the time of the click" as well as the "target" which is the "currently notified" element each time.
Search for more info here!