我真的很努力地發現這裏出了什麼問題,它只是不完全相加我在我的代碼中有另一個克隆的例子,但我發誓他們是一樣的,但這一個不工作? http://jsfiddle.net/a4KZs/試圖添加和刪除某個克隆以某種方式不起作用?
$("#addArrival/Departure").click(function(){
$(".question21:last").after($(".question21:first").clone(true));
});
$("#deleteArrival/Departure").click(function() {
if($(".question21").length!=1)
$(".question21:last").remove();
});
<div class="questiontext">
22. Arrival/Departure Details<br>
</div>
<div id="question21" class="input">
<div class="question21">
Arrival Date<br>
<select id="selectday4" class="daydate">
<option>Day</option>
<script>
var select = document.getElementById("selectday4");
var options = new Array();
var temp = 1;
for(var i = 0; i < 31; i++) {
options.push(temp);
temp++;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select>
<select id="selectmonth4" class="monthdate">
<option>Month</option>
<script>
var select = document.getElementById("selectmonth4");
var options = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
for(var i = 0; i < options.length; i++)
{
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
</script>
</select>
<select id="selectyear4" class="yeardate">
<option>Year</option>
<script>
var select = document.getElementById("selectyear4");
var options = new Array();
var firstyear = (new Date().getFullYear()) - 18;
var temp = firstyear;
for(var i = 0; i < 83; i++) {
options.push(temp);
temp--;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select><br>
City/Port of Arrival<br>
<input type="text" name="arrival/departure" class="textbox"><br>
Flight/Ship<br>
<input type="text" name="arrival/departure" class="textbox"><br>
Departure Date<br>
<select id="selectday5" class="daydate">
<option>Day</option>
<script>
var select = document.getElementById("selectday5");
var options = new Array();
var temp = 1;
for(var i = 0; i < 31; i++) {
options.push(temp);
temp++;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select>
<select id="selectmonth5" class="monthdate">
<option>Month</option>
<script>
var select = document.getElementById("selectmonth5");
var options = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
for(var i = 0; i < options.length; i++)
{
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);
}
</script>
</select>
<select id="selectyear5" class="yeardate">
<option>Year</option>
<script>
var select = document.getElementById("selectyear5");
var options = new Array();
var firstyear = (new Date().getFullYear()) - 18;
var temp = firstyear;
for(var i = 0; i < 83; i++) {
options.push(temp);
temp--;}
for(var i = 0; i < options.length; i++) {
var opt = options[i];
var el = document.createElement("option");
el.textContent = opt;
el.value = opt;
select.appendChild(el);}
</script>
</select><br>
City/Port of Departure<br>
<input type="text" name="arrival/departure" class="textbox"><br>
Flight/Ship<br>
<input type="text" name="arrival/departure" class="textbox"><br>
Country of Destination<br>
<input type="text" name="arrival/departure" class="textbox"><br>
</div>
</div>
<div id="adddeleteArrival/Departure">
<div id="addArrival/Departure">
<input type="button" value="Add Arrival/Departure">
</div>
<div id="deleteArrival/Departure">
<input type="button" value="Delete Arrival/Departure">
</div>
</div>
您可能想解釋重現您的問題? – HaBo