$(document).on("click", ".dynamicallyCreatedElement", function() { console.log('click');});因此,您将on处理程序绑定到document本身(或者实际上是新元素将出现"的容器元素-感谢@ devnull69的阐明),然后将其传递给事件类型和选择器.在 live 文档页面的中途,您会找到几个示例./p>As described on http://api.jquery.com/live/:Right. So instead of $('.dynamicallyCreatedElement').live('click', function(){ console.log('click');});I should use:$('.dynamicallyCreatedElement').on('click', function(){ console.log('click');});However it does not bind event to elements created after on() calling. So is it really better live() method ?Am I missing something ? 解决方案 To use on in the same manner as live used to work you need to use it like:$(document).on("click", ".dynamicallyCreatedElement", function() { console.log('click');});So you bind the on handler to the document itself (or, actually, the container element where the new wlements will be "appearing" -- Thanks to @devnull69 for the clarification), then pass it an event type and the selector.You'll find a couple of examples halfway through the live documentation page. 这篇关于jQuery on()方法不会像live()那样绑定事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!