I have to use datepicker in wordpress site, in which a plugin creates fields dynamically with same name(array), same #id and same .class i try to use it using focus but i go
you have id="datepicker"
for all your datepicker inputs, but ids are supposed to be unique in a given DOM. use class="datepicker"
instead. and also, since you're using jquery anyways, you dont need to use vanilla javascript onclick
function.
demo: http://jsfiddle.net/swm53ran/331/
<div class="mytemplate" style="display: none;">
<input class="datepicker" type="text" name="name[]"/>
</div>
<div class="dates">
<div>
<input class="datepicker" type="text" name="name[]"/>
</div>
</div>
<input type="button" class="addmore" value="Add more">
$(document).ready(function() {
$('.addmore').on('click', function() {
$(".mytemplate").clone().removeClass("mytemplate").show().appendTo(".dates");
});
$(document).on("focus", ".datepicker", function(){
$(this).datepicker();
});
});