For example:
<div class="mainWrapper">
<div class="FirstLayer">
<input class="foo" value="foo" />
</div>
<div class="SecondLayer">
<div class="thirdLayer">
<input class="fee" />
</div>
</div>
</div>
Lets say I have the input.fee
as a jQuery object and I also need to get the value of input.foo
.
Now I know I can use a multitude of approaches such as $(this).parents(':eq(2)').find('.foo')
but I want to use this one method on layouts which will have varying levels and numbers of nodes.
So I am wondering if there is a method which will simply start from .fee
and just keep going up until it finds the first matching element, .prevAll()
does not appear to do this. There are many .foo
and .fee
elements and I need specifically the first one above the .fee
in context.