Possible Duplicate:
jquery: on vs live
I have code that works just fine using $('thing').live("mousemove", function(e) { and $('thing').live({mouseenter:function(e) {. I notice jquery said live is depreciated and to use on so i did. However it doesn’t seem to work the way i expect it to. I had mousemove events but since objects were loaded dynamically the events werent triggering which is why i use live. Now live works perfectly but when i use on as jquery suggested it seems to act like .mousemove and such. It works on objects that exist when the code is executed and not on dynamically added events (the whole reason i use live).
Is there a way to tell on to act like live and add events on new object? or do i use live?
You need to delegate your event if you want it to work for Dynamically added elements
anyStaticParent can be any parent container of
thing..To be more general you can always set that to
bodyAlso I see that
'thing'is not a specific element ..use
'.thing'– if Class'#thing'– if ID