jquery – html表中每行的最后一个td

栏目: jQuery · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/15357325/last-td-of-each-line-in-html-table

我知道之前已经有人问过,但我已经尝试过以前的解决方案而且他们不适合我.

我有一个HTML表格,由AJAX生成:

<table cellspacing="1" cellpadding="7" summary="Procedure Tabulate: Table 1" frame="box" rules="groups" class="table table-bordered table-hover">
    <thead>
        <tr>
            <th scope="col" class="c m Header"> </th>
            <th scope="col" class="c Header">reel</th>
            <th scope="col" class="c Header">budgete</th>
            <th scope="col" class="c Header">ecart</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th scope="row" class="l t RowHeader">Fours</th>
            <td class="r b Data">15 341,10</td>
            <td class="r b Data">15 540,90</td>
            <td nowrap="" class="r b Data">  -1.29% </td>
        </tr>
        <tr>
            <th scope="row" class="l t RowHeader">Hifi</th>
            <td class="r b Data">10 578,60</td>
            <td class="r b Data"> 9 962,50</td>
            <td class="r b Data">   6.18% </td>
        </tr>
        <tr>
            <th scope="row" class="l t RowHeader">Magneto</th>
            <td class="r b Data">10 090,10</td>
            <td class="r b Data">10 495,60</td>
            <td nowrap="" class="r b Data">  -3.86% </td>
        </tr>
        <tr>
            <th scope="row" class="l t RowHeader">Total</th>
            <td class="r b Data">36 009,80</td>
            <td class="r b Data">35 999,00</td>
            <td class="r b Data">   1.04% </td>
        </tr>
    </tbody>
</table>

我对表中的类没有太多控制权,因为它们是由另一组人使用SAS(统计分析软件)创建的.

我想得到tbody中每一行的最后一个td.

目前我已经有了以下jQuery来完成这项工作:

$( '#ajax-area table tbody tr td:last' ).addClass( 'result' );

这不是将类添加到td.

有没有人有办法解决吗?

尝试
$( 'table tbody tr td:last-child').addClass( 'result' );

演示: Fiddle

翻译自:https://stackoverflow.com/questions/15357325/last-td-of-each-line-in-html-table


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Agile Web Development with Rails, Third Edition

Agile Web Development with Rails, Third Edition

Sam Ruby、Dave Thomas、David Heinemeier Hansson / Pragmatic Bookshelf / 2009-03-17 / USD 43.95

Rails just keeps on changing. Rails 2, released in 2008, brings hundreds of improvements, including new support for RESTful applications, new generator options, and so on. And, as importantly, we’ve a......一起来看看 《Agile Web Development with Rails, Third Edition》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具