I’ve been reading about replacing jQuery live() functions with on(), but they only work the same way as non-live functions.
For example, using the $('a').on('click', function(){}); has the same effect as using: $('a').click(function(){});
I need to replicate the functionality of $('a').live('click', function(){});
because I’m adding elements to the page dynamically.
You need to provide a selector:
Where
#containeris theidof the static parent of all the relevant anchors.Try to attach the
onto the closest static parent.ondocs: