我有这样的JavaScript代码来创建和动态地在我的asp.net Web窗体添加HTML:添加HTML输入动态jQuery和asp.net
var i = 0;
function agregaCampos() {
i++;
var cantidad = '<td class="auto-style2"><input type="text" size="3" name="cantidad' + i + '" /></td>';
var codigo = '<td class="auto-style3"><input type="text" size="5" name="codigo' + i + '" /></td>';
var umedida = '<td class="auto-style4"><select class="dropdown1" name="umedida' + i + '"><option value="PIEZA">PIEZA</option></select></td>';
var descripcion = '<td class="auto-style5"><input type="text" size="70" name="cantidad' + i + '" /></td>';
var punitario = '<td class="auto-style6"><input type="text" size="12" name="punitario' + i + '" /></td>';
var importe = '<td class="auto-style7"><input type="text" size="12" name="importe' + i + '" /></td>';
$("#conceptos").append("<tr>");
$("#conceptos").append(cantidad);
$("#conceptos").append(codigo);
$("#conceptos").append(umedida);
$("#conceptos").append(descripcion);
$("#conceptos").append(punitario);
$("#conceptos").append(importe);
$("#conceptos").append("</tr>");
}
我想这个表的结束标记前添加控件:
<div id="conceptos">
<table class="factura">
<tr>
<th class="auto-style2">Cantidad</th>
<th class="auto-style3">Código</th>
<th class="auto-style4">U. de médida</th>
<th class="auto-style5">Descripción</th>
<th class="auto-style6">Precio Unitario</th>
<th class="auto-style7">Importe</th>
</tr>
<----- Here
</table>
</div>
任何消化如何做到这一点?
DOM不是HTML的字符串。您可以添加整个元素(或者如果您愿意,可以完整填入HTML块),而不是单独打开和关闭标签。 – 2015-07-03 21:30:08
您想要订购行或隐藏与您的过滤器不匹配的行吗? – Beauceron