ReynierPM
ReynierPM

Reputation: 18680

Remove last TD before append the element

I have this jQuery code:

html += '<tr>';
html += '<td>AAA</td>';
html += '<td>BBB</td>';
html += '<td>CCC</td>';
html += '<td>DDD</td>';
html += '<td>EEE</td>';
html += '<td>FFF</td>';
html += '</tr>';

$(html).appendTo("#fabricanteBody");
$(html).appendTo("#selFabricanteBody");

How do I remove the last td (html += '<td>FFF</td>') element on the html var before append it to #selFabricanteBody?

Upvotes: 0

Views: 547

Answers (1)

Mohamed-Yousef
Mohamed-Yousef

Reputation: 24001

$('tr > td:last-child').remove();

or

$('tr > td').last().remove();

see demo HERE and HERE.

Upvotes: 10

Related Questions