I am trying to access datepicker() for each textbox dynamically added. here is my code :
<div id="parent">
Date: <input type="text" class="datepicker"><input type="button"value="Add" id="btn">
</div>
$(function() {
$( ".datepicker" ).datepicker();
});
$(document).ready(function () {
$("#btn").click(
function () {
AlertSave();
}
);
});
function AlertSave() {
var textBox = document.createElement("input");
textBox.setAttribute("class","datepicker");
document.getElementById("parent").appendChild(textBox);
}
But my problem is , the first texbox shows datepicker. but the newly added textfield doen't shows datepicker. What's wrong with my code?