I'm cloning a textarea in a page but the cloned element doesn't have any event of the primary element, is there any way to clone all events in cloned element?
var dupNode = node.cloneNode(deep);
I'm cloning a textarea in a page but the cloned element doesn't have any event of the primary element, is there any way to clone all events in cloned element?
var dupNode = node.cloneNode(deep);
You can maybe use
getEventListeners
on nodes? Don't know how the support is, or if it's only supported in the console?But it seems that
getEventListeners
isn't really supported:Get event listeners attached to node using addEventListener
If you need to copy all event properties on the node as well you will need a list of all, and then simply copy them over:
I was solving this problem lately and even that this is old post, just in case somebody is trying to find out, i add my solution :
Instead of using
addEventListener
, just create functionFunctionName
. Well this is useless if you are extending objects that useaddEventListener