In jQuery there is prev()
method which returns the previous element in DOM. But my question is is there any possibility to get the previous element of some specific tag using $(this)
keyword. I am trying $(this).prev()
to select the 3rd element, but it doesn't work (at least on forms).
<div>
<span class="item item-1">Item 1</span>
<span class="item item-2">Item 2</span>
<span class="item item-3">Item 3</span>
<span class="item item-4">Item 4</span>
<span class="item item-5">Item 5</span>
<a href="#">Click</a>
</div>