簡體   English   中英

jQuery排除第一,第二和最后一個表格行

[英]jQuery exclude first, second and last table row

我不包括第一行和最后一張表行來計算摘要。 現在,通過合並添加了另一個標題。 所以我也需要跳過第二行。 所以我需要跳過

第一,第二和最后。 我添加了tr:not(:first,second,last)但它不起作用。 我可以知道如何在此腳本中跳過表格的第二行。

謝謝,

 $(".printer-type tr:not(:first, last) td:last-child").text(function() { var totalVal = 0; $(this).prevAll().each(function() { totalVal += parseFloat($(this).children('.txtfld').val()) || 0; //totalVal += parseInt( ); }); return parseFloat(totalVal).toFixed(1); }); 

您可以使用:lt(index)

選擇index小於匹配集中索引的所有元素。

$(".printer-type tr:not(:lt(2), :last) td:last-child")

:gt(index)也可以使用

選擇index大於匹配集中索引的所有元素。

$(".printer-type tr:gt(1):not(:last) td:last-child")

:last用於最后一項,而:eq (index)用於第二項

可以使用slice()代替選擇器

$('.printer-type tr').slice(1,-1).children(':last-child')

演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM