yigitozmen yigitozmen - 4 years ago 170
Javascript Question

Jquery, how to get value of the next of the next element

i want to get value of the second element after the input.
Here is the code:

<div class="col-md-12 nopadding lines">
<label><input type="checkbox"> {{$e->title}}
<small class="desc">/ @if($i->ctype==0) Daily@else Weekly @endif</small>
<small class="price">{{$e->price}} TL</small></label>
</div>


This code iterates in foreach. So i have a lot of this block.
I want to reach price value in success function of ajax.
How can i get this value?

Answer Source

You could either chain two .next() methods:

$('input').next().next();

or you could use .nextAll() and .eq() in order to get the second sibling:

$('input').nextAll().eq(1);

Of course if you know the second element's class, you can specify that as well:

$('input').nextAll('.price').first();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download