Is it possible to get anywhere a pure Javascript function for event handler with similar functionality as jQuery’s live() ? I need to have the ability to attach events to objects not yet created but both jquery-livequery as well as jquery-events sources are not useful due to dependencies on jQuery core.
Is it possible to get anywhere a pure Javascript function for event handler with
Share
Event delegation is quite simple. Take this example:
Markup:
Script:
Since the event handler is attached to the parent, it will work for any future elements inserted.
You can try it here.
Useful reference: