删除id,并删除hasDatepicker
//+ -
function changeRows(sender,desc){
var tr = $(sender).closest("tr");
var table = tr.parent();
if(desc<0){
if(table.find("tr").length>1){
tr.remove();
}else{
tr.find("input[type=text]").val("");
tr.find("input[type=checkbox]").removeAttr("checked");
}
}else{
var newrow = $(tr).clone(true);
$(tr).after(newrow);
newrow.find(".date").removeAttr("id").removeClass('hasDatepicker').datepicker({ dateFormat: 'yy-mm-dd' });
newrow.find("input[type=text]").val("");
newrow.find("input[type=checkbox]").removeAttr("checked");
}
}
参考:
ar $clone=$(".datepicker").clone(); $clone.datepicker("destroy"); $clone.removeAttr("id"); $clone.datepicker(); $('form').append($clone);
http://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&prev=/search%3Fq%3Ddatepicker%2Bclone%26newwindow%3D1%26safe%3Dstrict%26es_sm%3D93&rurl=translate.google.com.hk&sl=en&u=http://stackoverflow.com/questions/19150968/how-to-clone-jquery-datepicker-input-field&usg=ALkJrhjn0EN3-_w2Yi4EAf6yB131_oTTbQ