.on()jQuery无法正常工作

This question already has answers here:
                </div>
            </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2013-01-08 18:46:45Z" class="relativetime">7 years ago</span>.</div>
        </div>
    </aside>

Possible Duplicate:
jQuery - convert .live() to .on()
JQuery ‘on’ vs. ‘live’
Turning live() into on() in jQuery

I know .live() is deprecated, but .on() is getting me some errors. It does not work when I dynamically generate the dome, it only works at the first click. Whilst the same code with .live() works correctly. I'm using jquery 1.8

Working code

$('.item').live('click', function(e) {
   alert('test');
   // ajax call that regenerates .item element
});

This code only works at the first click:

$('.item').on('click', function(e) {
   alert('test');
   // ajax call that regenerates .item element
});

What's wrong?

</div>

Since the dom change with your Ajax you need to provide a parent on your on call like this:

$("#itemParent").on("click", ".item", function(event){
  alert('test');
});

As Kevin B mentioned, use document as context of delegation, or better static parent:

$(document).on('click','.item', function(e) {
   alert('test');
   // ajax call that regenerates .item element
});

Check the documentation here. .on works slightly different:

$(document).on("click", ".item", function(event){
    alert('test');
    // ajax call that regenerates .item element
});