Replacing jQuery live with on

.live() function is removed on jQuery version 1.9.

So if you want the same behaviour, you can use on with versions gte 1.9.

Let’s say we have a code that’s like:

$(“#serviceItemsContainer input“).live(“change”, function(){ /* some code */ });

then this code block can be changed like that:

$(“#serviceItemsContainer”).on(“change”, “input”, function(){ /* some code */ });

Notice, there is an extra parameter to pass the function as a selector. This way you can attach a function without having the item on DOM, when you execute the code.

Happy Coding

References:

https://api.jquery.com/live/

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

http://weblog.west-wind.com/posts/2013/Jun/12/Replacing-jQuerylive-with-jQueryon