<<Index

Event Delegation

When adding elements dynamically the normal style of writing an event will not work. This is because nodes that are added dynamically to the DOM are registered to receive an event. To get round this we can use delegation. Here we assign the event to an object higher up the DOM that was present when the document first loaded and then use an additional parameter of the 'on' event to indicate the new target of the event.

Created by: