Open In App

Difference between on() and live() or bind() in jQuery

jQuery offers various event handlers like on(), live() and bind(). Though, there are some minor differences which are discussed below.

bind() method: This method only attaches events to elements which exist beforehand i.e. state of initialized document before the events are attached. If the selector condition is satisfied for an event afterward, bind() will not work on that function. It also won’t work in the case if selector condition is removed from the element.



live() method: This method attaches events not only to existing elements but also for the ones appended in the future as well but it won’t work in the case if selector condition is removed from the element.

Note: The live() method was deprecated in jQuery version 1.7, and removed in version 1.9.



on() method: This method attaches events not only to existing elements but also for the ones appended in the future as well. The difference here between on() and live() function is that on() method is still supported and uses a different syntax pattern, unlike the above two methods.

Differences summarized for the above methods:

Property bind() live() on()
Deprecated Yes Yes No
Removed No Yes No
Scope Elements initialized beforehand For both current and future event binding For both current and future event binding
Syntax: $([selector]).bind([event],[function]); $([selector]).live([event],[function]); $(document).on([event],[selector],[function]);

Article Tags :