Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery's live() is deprecated. What do I use now?

I saw on the jquery documentation that live() is deprecated. Is there a direct replacement function?

like image 958
lowerkey Avatar asked Feb 23 '12 22:02

lowerkey


2 Answers

$(document).on('event', 'selector', function() {}); replaces .live().

$('selector').on('event', 'selector', function() {}); replaces .delegate().

$('selector').on('event', function() {}); replaces .bind().

like image 73
DarthJDG Avatar answered Nov 10 '22 05:11

DarthJDG


Of course:

http://api.jquery.com/on/

http://api.jquery.com/off/

The page for live() shows how to convert to on():

http://api.jquery.com/live/

like image 39
biziclop Avatar answered Nov 10 '22 06:11

biziclop