读取具有许多单元格的表行的索引值,并使用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);
});