getting a specific adjacent element in jquery
if I have the following table:
<tr class="alternate">
<td>{$order.titel}</td>
<td>{$order.auteur}</td>
<td>€{$order.prijs}</td>
<td>{$order.aantal}</td&开发者_Go百科gt;
<td>€ {$order.aantal*$order.prijs}</td>
<tr>
and inside jquery I currently have the 4th td selected, how can i get the data from within the first td, keeping in mind that I start looking from the 4th td (eg. the 4th td is 'this')?
var first = $(this).siblings().first();
Or, for one of the other elements:
var second = $(this).siblings().eq(1);
You can use the prev() method which returns the preceding sibling.
var first = $(this).prev().prev().prev();
精彩评论