开发者

How do I manipulate first table cell in table row based on values in second and third table cell

开发者 https://www.devze.com 2022-12-16 14:35 出处:网络
I would like to manipulate first table cell in a table row based on values in second and third table cell. This h开发者_高级运维as to be done for each table row.

I would like to manipulate first table cell in a table row based on values in second and third table cell. This h开发者_高级运维as to be done for each table row.

Is this possible with jQuery?


Something like this would work:

$(document).ready(function() {
    $('#tbl tr td:nth-child(1)').each(function() {
       var siblings = $(this).nextAll('td');
     $(this).html(siblings.eq(0).html() + siblings.eq(1).html());
    });
});

try it on this:

<table id="tbl">
 <tr>
   <td>one</td>
   <td>two</td>
   <td>three</td>
 </tr>
 <tr>
   <td>1</td>
   <td>2</td>
   <td>3</td>
 </tr>
</table>
0

精彩评论

暂无评论...
验证码 换一张
取 消