JQuery – Use The “On()” Method Instead Of “Live()”

As of jQuery 1.7, the .live() method is deprecated.Use.on() to attach event handlers.

Description: Attach an event handler function for one or more events to the selected elements.
The .on() method attaches event handlers to the currently selected set of elements in the jQuery object.

Syntax:-
.on(events[,selector][,data],handler(eventObj))
.on(eventType, selector, function)

Examples:-
$(“body”).on(“click”, “#element”, function(){
$(“#my”).html(result);
});

$(“body”).on(“click” , “p” ,function(){
alert($(this).text());
});

Migration from .live() to .on()
before:
$(‘#mainmenu a’).live(‘click’, function)
after, you move the child element (a) to the .on() selector:
$(‘#mainmenu’).on(‘click’, ‘a’, function)

Have questions? Contact the technology experts at InApp to learn more.

Ready to Build
Something
Extraordinary?

Join 300+ companies who trust us to turn their biggest ideas into market-leading solutions.

Our Global Team
500+ Engineers Worldwide
SOC 2 Certified

Get in Touch with Us

Our Global Team
500+ Engineers Worldwide
SOC 2 Certified

InApp India Office

121 Nila, Technopark Campus
Trivandrum, Kerala 695581
+91 (471) 277 -1800
mktg@inapp.com

InApp USA Office

999 Commercial St. Ste 210 Palo Alto, CA 94303
+1 (650) 283-7833
mktg@inapp.com

InApp Japan Office

6-12 Misuzugaoka, Aoba-ku
Yokohama,225-0016
+81-45-978-0788
mktg@inapp.com
Terms Of Use
© 2000-2026 InApp, All Rights Reserved