// jQuery datepicker
(function() {
var d = new Date();
var maxD = new Date(d.setDate(d.getDate()));
$('.datepick').datepicker({changeMonth: true,changeYear: true,yearRange: "-31:+10",dateFormat: "MM dd, yy"});
})();
// apply the datepick class to a dynamically create input field
var cell = document.createElement("td");
var cellText = document.createElement('input');
cellText.type = 'text';
cellText.name = 'aDate[]';
// cellText.addClass = 'datepick';
$('.gdate').on('click', function() {
$(this).datepicker('destroy').datepicker({changeMonth: true,changeYear: true,dateFormat: "yy-mm-dd",yearRange: "+10",showOn:'focus'}).focus();
});
cell.appendChild(cellText);
No error, however, the datepicker failed to be applied to the dynamically created input field. What's supposed to be the correct syntax for that?
Thanks.