大家有什么可以解释一下,如何克隆日期选择器文本字段以便下面的代码。以下是jsp。
$("#workexperience").click(function() {
var jobfromdate = 0;
var remve = '<td><button type="button" class="removeworkexperience" class="btn btn-info" >x</button></td>';
$(this).closest('tr').prev('tr').clone(true).insertAfter($(this).closest('tr').prev('tr')).find('td:last-child').remove();
$(this).closest('tr').prev('tr').append(remve);
$('input[id^="jobfromdate"]').each(function() {
$(this).attr('id', this.id + jobfromdate);
$('#jobfromdate' + jobfromdate).datepicker();
jobfromdate++;
alert(1);
});
JSP
<tr>
<td>
<input type="text" id="previouscompanyname" name="previouscompanyname" maxlength="200" class="input-large" style="height:27px; " value="${param.previouscompanyname}"/>
<p id="previouscompanyname" style="color: red"/>
<html:errors property="previouscompanyname"/>
</td>
<td>
<input type="text" id="jobtitle" name="jobtitle" maxlength="200" class="input-large" style="height:27px; " value="${param.jobtitle}"/>
<p id="jobtitle" style="color: red"/>
<html:errors property="jobtitle"/>
</td>
<td>
<input type="text" class="input-large datepicker" style="height:27px;" readonly="true" id="jobfromdate" name="jobfromdate" value="${param.dateofjoining}"/>
<html:errors property="jobfromdate"/> </td>
<td>
<input type="text" class="input-large datepicker" style="height:27px;" readonly="true" id="jobtodate" name="jobtodate" value="${param.dateofjoining}"/>
<html:errors property="jobtodate"/>
</td>
<td>
</td>
</tr>
<tr>
<td>
<button type="button" class="btn btn-info" id="workexperience">Add New</button>
</td>
</tr>