我在 jQuery 文档上看到 live() 已被弃用。是否有直接替代的函数?
我在 jQuery 文档上看到 live() 已被弃用。是否有直接替代的函数?
$(document).on('event', 'selector', function() {});
替换了 .live()
。
$('selector').on('event', 'selector', function() {});
替换了 .delegate()
。
$('selector').on('event', function() {});
替换了 .bind()
。
当然:
live()
页面展示了如何转换为on()
:
$('rootselector').on('click', 'selector', function(){
});
taken from http://api.jquery.com/on/