Skip to content Skip to sidebar Skip to footer

How To Clone Jquery Datepicker Input Field

I need to clone a jQuery datepicker input field attached a datePicker to it using the on statement. $('form').on('click', '.datepicker', function(){ $(this).datepicker({'c

Solution 1:

try this

var$clone=$(".datepicker").clone();
$clone.datepicker("destroy");
$clone.removeAttr("id");
$clone.datepicker();
$('form').append($clone);

when you clone a row it copies every thing, and when the date picker is added again it calls the input by id, you must remove the id so that the next datepicker can assign a new id to the input :)

Solution 2:

You should destroy the datepicker for the clone element like,

var$clone=$(".datepicker").clone();
$clone.datepicker('destroy').removeClass('hasDatepicker');
$('form').append($clone);

Post a Comment for "How To Clone Jquery Datepicker Input Field"