Possible Duplicate:
jQuery 1.7 - Turning live() into on()
According to the jQuery API (http://api.jquery.com/on/) the function 'live' is deprecated, it is recommended to use 'on' instead. But when I replace 'live' with 'on' in my code, jQuery can't find later added elements anymore:
This works (but is deprecated):
$('li.bibeintrag').live('click', function(){
alert('myattribute =' + $(this).attr('myattribute'));
});
This is an example from the API for 'on':
$("#dataTable tbody tr").on("click", function(event){
alert($(this).text());
});
When I change my code to this ('live' replaced with 'on') it does not work anymore (jQuery will not find later added elements (e.g. with append)):
$('li.bibeintrag').on('click', function(){
alert('myattribute =' + $(this).attr('myattribute'));
});
What am I doing wrong? Can someone help, please?