我有一个表格,其中每一行都包含一个表格。见下文
<table>
<tr><th>Fee Type</th><th>Amount</th><th>% Discount</th><th>Discounted Amount</th><th>Payable to</th><th>Remove</th></tr>
<tr>
<form>
<td></td>
<td class="cost"></td>
<td> <input /> </td>
<td class="discount"></td>
<td></td>
</form>
<tr>
</table>
现在我的意图是有一个全局保存按钮,它将遍历每个表单并执行 ajax 发布。见下文
function saveEditedFees(){
$("#savefeechanges").click(function(){
$("#feestable form").each(function(){
alert( $(this).attr('id') );
});
});
}
我的问题是使用 $(this) 访问“td”的值,用于 我尝试过的具有“成本”和“折扣”类的元素
alert( $(this).find("td").eq(2).html() );
alert($(this).siblings('.cost').text());
alert($("td .cost" ,this).text());
基本上,我正在尝试测试 中包含的值<td class="cost">
是否等于<td class="discount">
,这样我将有选择地做一个 ajax 帖子。
请帮忙。