我的选择框有问题。我使用 ms-dropdown https://github.com/marghoobsuleman/ms-Dropdown并将其与我的 ADD/REMOVE 表行集成。这是整个 jquery 脚本。
$(document).ready(function() {
var id = 0;
var n = 0;
// Add button functionality
$("table.dynatable button.add").click(function(e) {
e.preventDefault();
id++;
n++;
var master = $(this).parents("table.dynatable");
// Get a new row based on the prototype row
var prot = master.find(".prototype").clone();
prot.attr("class", "")
prot.find(".id").attr("value", id);
prot.find(".num").html(n);
master.find("tbody").append(prot);
});
// Remove button functionality
$("table.dynatable button.remove").live("click", function() {
$(this).closest("tr").remove();
});
$(".tech").msDropdown();
});
这是桌子
<table class="dynatable" align='center' id='dynatable' border='1'>
<thead>
<tr>
<th width='500px' colspan='2'>Window Type</th>
<th><button class="add">Add</button></th>
</tr>
</thead>
<tbody>
<tr class="prototype">
<td width='5px'>
<span class='num'>1</span>
</td>
<td>
<input type="checkbox" name="checkbox[]" value="0" class="id" id='checkbox' style='display:none;' checked/>
<select name='prod_type[]' class='tech' style='width:300px;'>
<option value='' data-description="Select Window/Door"></option><option value='Sample1' data-image="" data-description="This is sample 1">
Sample 1
</option><option value='Sample2' data-image="" data-description="This is sample 2">
Sample 2
</option><option value='Sample 3' data-image="" data-description="This is sample 3">
Sample 3
</select>
</td>
<td>
<button class="remove">X</button>
</td>
</tr>
</table>
问题是当您单击“添加”按钮时,它会追加一行,但选择框似乎已被禁用。我想知道为什么会发生这种情况..请帮助我..提前谢谢。
这是小提琴:http: //jsfiddle.net/jc_garcia0527/QzQ2q/