我有一个只有一行的表,我想动态添加其他行所以obviesley我使用函数clone()所以这里是代码
<table>
<th>New SL</th>
<th>condition</th>
<th>Sl donne</th>
<div id="conditions" numTypes="0">
<div class="condition clone" id="lol">
<tr>
<td align="center">
<select id="cond[0][new]" class="select-attribut">
<% @attribut.each do |att| %>
<option id="<%= att.id %>"><%= att.nom %></option>
<% end %>
</select>
</td>
<td align="center">
<select id="cond[0][operation]" class="select-operation">
<% @operation_attribut.each do |op| %>
<option id="<%= op.id %>"><%= op.nom %></option>
<% end %>
</select>
</td>
<td align="center">
<select id="cond[0][old]" class="select-attribut">
<% @attribut.each do |att| %>
<option id="<%= att.id %>"><%= att.nom %></option>
<% end %>
</select>
</td>
</tr>
<tr id="cond[0][tr_condition]" class="tr_condition">
<td>
<select id="cond[0][op_condition]" class="select-operation">
<% @operation_condition.each do |att| %>
<option id="<%= att.id %>"><%= att.nom %></option>
<% end %>
</select>
</td>
</tr>
</div>
<tr id="add">
<td align="left">
<button class="btn green plus-cond"><i class="icon-plus"></i></button>
</td>
</tr>
</div>
</table>
忽略&lt; %%&gt;它在轨道上的红宝石只是填补了选项
这里是Jquery代码
$(".plus-cond").bind("click",function(){
group = $(".clone").clone();
$("#add").before(group);
});
但是当我测试变量组时,它只包含没有子节点的父div