jQuery选择器,除了第一个之外的每一个表,除了第一个 [英] jQuery selector for every row except the first on every table except first
本文介绍了jQuery选择器,除了第一个之外的每一个表,除了第一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要对每个表格行的最后一个单元格应用右对齐,跳过页面上的第一个表格,跳过每个表格的第一行。
I want to apply right alignment on the last cell of every table row, skipping the first table on the page and skipping the first row of every table.
我写下:
$("table:gt(0) tr:gt(0) td:last-child").css("text-align", "right");
- 选择第一个表之后的表。 GOOD。
- 每一行中的最后一个单元格都对齐。 GOOD。
- 跳过结果集中第一个表格的第一行。 GOOD。
- 结果集中后续表中的每个第一行都应用了样式。 BAD。
- The tables after the first are selected. GOOD.
- The last cell in each row is aligned right. GOOD.
- The first row in the first table in the result set is skipped. GOOD.
- Each first row in subsequent tables in the result set has the style applied. BAD.
我试过将一个函数传递给包装集上的each方法,但这不工作。任何想法?
I've tried passing a function to the "each" method on the wrapped set, but that isn't working. Any ideas?
推荐答案
你几乎在那里。
$("table:gt(0)").find("tr:gt(0) td:last-child").css("text-align", "right");
否则,tr:gt(0)总是为真,因为jquery正在查看每个tr, tr在每个表中。
otherwise, tr:gt(0) is always true because jquery is looking at each tr, not each tr in each table.
这篇关于jQuery选择器,除了第一个之外的每一个表,除了第一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文