Function doesnot get attached with newly created input box. Please check my code on this link
[Please check this code][1]
$("#datepicker").datepicker();
$("button").click(function(){
$(".add").html('<input id="datepicker" placeholder="click here to open calendar " type="text" />');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='add'><input id="datepicker" placeholder="click here to open calendar " type="text" /></div>
<button>Add input again </button>
depen.io/anon/pen/adLzi