jQuery检测通过ajax添加的元素

ste*_*tef 1 jquery

当页面加载后,当通过ajax将具有class ='crit'的选择字段插入页面时,以下内容不响应,然后进行更改.我怎么能这样做?

$(".crit").click(function(){alert("hello")})
Run Code Online (Sandbox Code Playgroud)

Thi*_*ter 7

用这个:

$('.crit').live('click', function(e) {
    alert('hello');
});
Run Code Online (Sandbox Code Playgroud)

常规事件仅绑定到当前存在的元素.当使用live()事件处理程序绑定到文档本身并且由于事件冒泡,它不会不需要将处理程序附加到实际元素.