Jquery1.10 is a method that binds events to the new element
- 2020-03-30 02:14:14
- OfStack
Query1.10 removes the.live() method and adds a.on() method to bind events to elements.
On (the events, the selector, [data], fn)
The above method binds events to all of this tr, but cannot bind events to new elements.
The above method binds an event to the tbody, where the tr can trigger the click event if the tr is a new element.
On (the events, the selector, [data], fn)
$("#dataTable tbody tr").on("click", function(event){
alert($(this).text());
});
The above method binds events to all of this tr, but cannot bind events to new elements.
$("#dataTable tbody").on("click", "tr", function(event){
alert($(this).text());
});
The above method binds an event to the tbody, where the tr can trigger the click event if the tr is a new element.