//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)时输入文本框。 我可以读取值但是在单击时无法读取链接的索引。我想知道如何应用每个函数来读取链接的索引。一旦我读完了不法行为,我就可以用相应的值更新td。
请帮忙。我如何阅读文字?
答案 0 :(得分:1)
我猜你在点击clickChange
时想要索引。
$("td.clickchange").click(function() {
var i = $(this).parent("tr").index();
alert(i);
});