jQuery-获取< td>的值行数超过一个的标签 [英] Jquery - get value of <td> tag that has rowspan more than one

查看:88
本文介绍了jQuery-获取< td>的值行数超过一个的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态表,该表取决于abc1列的数量.
在此示例中,我在abc1列中有2行.其值为18和23
http://jsfiddle.net/SdN4L/

i have a dynamic table that depend on quantity of abc1's column.
In this example i have 2 rows in abc1 column. that has value is 18 and 23
http://jsfiddle.net/SdN4L/

<table border=1>
    <tr>
        <th rowspan="2"></th>
        <th rowspan="2"></th>
        <th rowspan="2"></th>
        <th rowspan="2"></th>
        <th rowspan="2"></th>
        <th align="center" colspan="3">abc</th>
        <th rowspan="2"></th></tr>
    <tr>
        <th>abc1</th>
        <th>abc2</th>
        <th>abc3</th>
    </tr>
    <tr>
        <td rowspan="2">2</td>
        <td rowspan="2">16</td>
        <td rowspan="2">a</td>
        <td rowspan="2">300</td>
        <td rowspan="2">b</td>
        <td>18</td>
        <td>c</td>
        <td>333</td>
        <td rowspan="2">31</td>
        <td rowspan="2"><input type="button" value="Edit" name="edit" class="edit"></td>
        <td rowspan="2"><input type="button" value="Delete" name="delete"  class="delete"></td>
        <td rowspan="2"><input type="button" value="Add" name="add"  class="add"></td>
    </tr>
    <tr>
        <td>23</td>
        <td>d</td>
        <td>322</td>
    </tr>
</table>

当我单击编辑"按钮时我想做.它将显示下一行的值,如3步. 我不知道该怎么做3个步骤.我怎样才能做到这一点.谢谢

i want to do when i click to edit button. it will show value of next row like 3 step. i don't know how to do 3 steps. how can i do that. thanks

$('.edit').click(function(){
    //1: get rowspan value of <td rowspan="2">edit input</td>
    //2: for (i=1; i < rowspan.value; i++)
    //3:     alert('text of abc2') = 23 and d and 322
    alert ($(this).parent().siblings().eq(7).text());
});

推荐答案

您可以轻松获得rowpan值:

You can get the rowspan value easily:

$(this).parent().siblings().eq(0).attr("rowspan");

这篇关于jQuery-获取&lt; td&gt;的值行数超过一个的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆