读取具有许多单元格的表行的索引值,并使用Jquery从中读取值 [英] reading index value of a table row with many cells and reading the value from it using Jquery

查看:87
本文介绍了读取具有许多单元格的表行的索引值,并使用Jquery从中读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//PHP array   
 $Cashups = array(
    array(
        'cashup_id' => 146456,
        'display_time' => 'Wed 16th Mar, 9:55pm',
        'terminal_name' => 'Bar 1',
        'calculated_cash' => 389.20,
        'actual_cash' => 374.6,
        'calculated_tenders_total' => 1,551.01,
        'actual_tenders_total' => 1,551.01
    ),
    array(
        'cashup_id' => 146457,
        'display_time' => 'Wed 16th Mar, 9:56pm',
        'terminal_name' => 'Bar 2',
        'calculated_cash' => 493.3,
        'actual_cash' => 493.3,
        'calculated_other' => 1509.84,
        'actual_other' => 1509.84
    )
);

HTML

<?php foreach ($Cashups as $Cashup) { ?> 
<tr>
    <td class="Left"><?php echo $Cashup['display_time']; ?></td>
    <td><?php echo $Cashup['terminal_name']; ?></td>
    <td><?php echo number_format($Cashup['calculated_cash'], 2); ?></td>
    <td class="clickchange"><a  href="#"><?php echo number_format($Cashup['actual_cash'], 2); ?></a></td>
    <td><?php echo number_format($Cashup['calculated_other'], 2); ?></td>
    <td><?php echo number_format($Cashup['actual_other'], 2); ?></td>
</tr>
<?php } ?>

jQuery

当用户在stackoverflow上发送的答案的帮助下,单击链接(clickchange)时,我能够输入文本框. 我可以读取这些值,但是单击后无法读取链接的索引.我想知道如何将每个on函数应用于读取链接的索引.读取完inexe后,我便可以使用各自的值更新td.

I am able to input text boxes when clicked on the link(clickchange) with the help of an answer sent by user on stackoverflow. I can read the values but am not able to read the indexes of the links when clicked. I would like to know how to apply each on function to read the indexes of the link. Once I read the inexes I can then update the td with thier respective values.

请帮助.如何阅读文字?

Please help. How do I read text?

推荐答案

我猜想单击clickChange时需要索引.

I am guessing you want the index when clickChange is clicked.

$("td.clickchange").click(function() {
    var i = $(this).parent("tr").index();
    alert(i);
});

这篇关于读取具有许多单元格的表行的索引值,并使用Jquery从中读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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