开发者

jQuery to find previous elements

I have the following table

<table>
<tr class="ligneI">
<td class="col2b"><input type="text" id="desc" class="calcule"></td>
<td class="col2b"><input type="text" id="price" class="calcule"></td>
<td class="calculated_price">220.00</td>
<td class="calculated_price">1800.00</td>
<td><a title="" class="picto06 deleteLink" id="deleteLink1" href="#" onclick="resetfields(this);">delete</a></td>
</tr>
<tr class="ligneI">
<td class="col2b"><input type="text" id="desc" class="calcule"></td>
<td class="col2b"><input type="text" id="price" class="calcule"></td>
<td class="calculated_price">87.00</td>
<td class="calculated_price">40.00</td>
<td><a title=""开发者_StackOverflow class="picto06 deleteLink" id="deleteLink2" href="#" onclick="resetfields(this);">delete</a></td>
...

and I would like to reset the entire when i click on a delete link.

I tried to do something like this:

function resetfields(obj)
{
    $(this).parent().prevAll('td.calcule').html('&nbsp;');
    $(this).parent().prevAll('td input.calcule').val('');
}

but only the first line erase the two first befor my link. Someone can help me please.

Ps : excuse my english


Try this:

$(this).closest('tr').find('td.calculated_price').html('&nbsp;');
$(this).closest('tr').find('td input.calcule').val('');


Please try this:

$(this).parent().parent().find('td.calculated_price').html(""); //doing parent().parent() to get to TR
$(this).parent().parent().find('td.calcule').val("");

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜