开发者

getting a specific adjacent element in jquery

开发者 https://www.devze.com 2023-01-22 07:21 出处:网络
if I have the following table: <tr class=\"alternate\"> <td>{$order.titel}</td> <td>{$order.auteur}</td>

if I have the following table:

<tr class="alternate">
    <td>{$order.titel}</td>
    <td>{$order.auteur}</td>
    <td>&euro;{$order.prijs}</td>
    <td>{$order.aantal}</td&开发者_Go百科gt;
    <td>&euro; {$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();
0

精彩评论

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