I am trying to add datepicker to new textboxes created using document.createElement().
I am assigning the datepicker to a class called pickDate:
$(function () {
$('.pickDate').datepicker({ dateFormat: "dd/mm/yy" });
});
It works fine with input elements generated on page load.
The function I am using to create new input textboxes contains the following:
function addNew() {...
var newDate = document.createElement('input');
newDate.type = "input";
newDate.id = "date";
newDate.className = "pickDate"; .....}
The new textboxes are created fine but no datepicker. From my research online I think I must use onfocus() and bind it?
Note: I must use a class instead of id in this example.
Unfortunately I am very new to javascript and jquery and this is as far as I can go. Any variation I try doesn't seem to work.