I am trying to add a Jquery calendar picker to a text box at the time of creation, but I cant find how.
When I press a button, it will create a table, the element I want to attach the Jquery calendar picker is:
var txtDate = createTextInput(i, "txtDate", 8, 10);
txtDate.className = "datepicker";
this.newcells[i].appendChild(txtDate);
I tried adding at the end :
txtDate.datepicker();
But does not work. Can anybody help?
Thanks.
Note: CreateTextInput is:
function createTextInput(i, strName, size, maxLength) {
var input = document.createElement('<input>');
input.type = "text";
input.name = strName;
input.id = strName + i;
input.size = size;
input.maxLength = maxLength;
return input;
}
Use
instead of
You can create an element using jQuery with ease. Something like
You can rewrite the createtextinput function like this in jQuery
If you are returning the jQuery object then you can directly call datepicker(), like