Possible Duplicate:
jQuery 1.7 – Turning live() into on()
.live() vs .on() method
I have the following code (which I’ve simplified for this) which worked fine alongside jquery-1.7.
$("td.ui-datepicker-week-col a").live("click", function () {
alert("hello");
});
I’m trying to upgrade my code though so I can upgrade my jQuery pack version so I’ve changed it to this.
$("td.ui-datepicker-week-col").on("click", "a", function () {
alert("hello");
});
This doesn’t do anything though. It doesn’t throw any errors either so I can’t see where the problem is.
Any ideas?
If you don’t have
"td.ui-datepicker-week-col"element at start, then you must choose an existing permanent set. For exampleThe
onfunction, contrary tolive, will only work with the set as it is defined when you call the binding function. What is dynamic is the interpretation of the selector passed as argument toonwhen an event occurs.