I’m using jQuery 1.4.4 and I’m stuck trying to add a datepicker dynamically by id. Here is the code:
$(function () {
$('#ListTableBody').find('input[id^="PickDate."]').each(function () {
alert(this.id);
$(this.id).datepicker();
});
});
I’m using a table that dynamically generates the id’s on the fly. The code above finds each of the id’s and I verified it using the alert. As I loop through, this.id shows I’ve got the right id and input, but the datepicker doesn’t work for some reason? Also, I don’t throw any errors.
Any ideas what I’m doing wrong here?
Try this :
no need to get the
idattribute – you can makethisa jQuery object immediately