jQuery: how to replace .live with .on?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8021436/jquery-1-7-turning-live-into-on">jQuery 1.7 - Turning live() into on()</a>  </p>
</blockquote>



<p>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:</p>

<p>This works (but is deprecated):</p>

<pre><code>$('li.bibeintrag').live('click', function(){
alert('myattribute =' + $(this).attr('myattribute'));
});
</code></pre>

<p>This is an example from the API for 'on':</p>

<pre><code>$("#dataTable tbody tr").on("click", function(event){
    alert($(this).text());
});
</code></pre>

<p>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)):</p>

<pre><code>$('li.bibeintrag').on('click', function(){
alert('myattribute =' + $(this).attr('myattribute'));
});
</code></pre>

<p>What am I doing wrong? Can someone help, please?</p>
