Skip to content Skip to sidebar Skip to footer

Modify `target` Of Mouseevent Object For Event Delegation

Is it possible to modify the target property of a mouseEvent? I have an event delegator function, delegator(parentSelector, childSelector, event, callback), which is used to bind e

Solution 1:

The target of a mouseEvent is read only, so you won't be able to modify it with traditional methods. However, you can set a new variable, for instance:

e.desiredTarget = currentTarget;

Then you can reference e.desiredTarget anywhere that you want to use e.target.

Post a Comment for "Modify `target` Of Mouseevent Object For Event Delegation"