jQuery to find previous elements

Posted by mike on Stack Overflow See other posts from Stack Overflow or by mike
Published on 2010-04-13T15:02:45Z Indexed on 2010/04/13 15:33 UTC
Read the original article Hit count: 277

Filed under:
|

Hi everybody, 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="" 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

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery