我是jQuery的新手,並且在這個問題上停留了很長一段時間。jquery ui datepicker不能添加新的輸入字段
我在輸入字段中使用jQuery ui datepicker,它是在單擊按鈕時動態添加的。日期選取器僅適用於輸入框的第一個實例。已嘗試尋找解決方案,但沒有運氣。任何幫助將不勝感激。由於
jQuery代碼
$(".datepicker").datepicker({
inline: true,
dateFormat: "yy-mm-dd"
});
HTML代碼
<div id="newlink">
<div>
<table style="border: 1px solid black;">
<tr>
<th>Date:</td>
<td>
<input type="text" name="linkurl[]" id="Editbox18" class="datepicker" style="width: 147px; height: 23px; z-index: 2; color: black" autocomplete="off">
</td>
</tr>
<tr>
<th>Remark:</td>
</tr>
<tr>
<td>
<textarea name="linkdesc[]" size="1" id="Editbox19" style="width: 550px; height: 45px; z-index: 2; color: black" autocomplete="off"></textarea>
</td>
</tr>
</table>
<br>
</div>
</div>
<br>
<p id="addnew">
<input onclick="new_link()" type="button" name="linkdesc[]" value="Add More" style="width: 80px; height: 24px; z-index: 136; color: black;">
</p>
<!-- Template -->
<div id="newlinktpl" style="display: none"> <font size="1.5">
<hr style="width: 75%; margin-left: -5px;" /> <br />
<div>
<table style="border: 1px solid black;">
<th>Date:
</td>
<td><input type="text" name="linkurl[]" id="Editbox"
class="datepicker"
style="width: 147px; height: 23px; z-index: 2; color: black"
autocomplete="off"></td>
</tr>
<tr>
<th>Remark:
</td>
</tr>
<tr>
<td><textarea name="linkdesc[]" size="1" id="Editbox19"
style="width: 550px; height: 45px; z-index: 2; color: black"
autocomplete="off"></textarea></td>
</tr>
<script type="text/javascript">
var ct = 1;
function new_link() {
ct++;
var div1 = document.createElement('div');
div1.id = ct;
// link to delete extended form elements
var delLink = ' <input onclick="delIt(' + ct
+ ')" type="button" value="Del" style="position:relative; top:-20px; left:600px; color:black; width:50px;height:20px;z-index:136;">';
div1.innerHTML = document.getElementById('newlinktpl').innerHTML + delLink;
document.getElementById('newlink').appendChild(div1);
}
// function to delete the newly added set of elements
function delIt(eleId) {
d = document;
var ele = d.getElementById(eleId);
var parentEle = d.getElementById('newlink');
parentEle.removeChild(ele);
}
</script>
</td>
</tr>
</table>
</div>
</font>
</div>
可能重複的()上動態創建的元素 - JQuery/JQueryUI](http://stackoverflow.com/questions/10433154/putt這個解決方案,從第二個添加的容器/元素選擇器用戶界面顯示出來,但輸入框並沒有從中獲得價值:( – showdev