I am loading some HTML elements via jQuery:
Considder this case:
<li>test</li> (1)
<li>test</li> (2)
<li>test</li> (3)
If i do:
$("body").find('li:last')
I will get the last li element, the one i marked (3) and if i was always sequentially adding items that would be fine. However if i add a new element in between:
<li>test</li> (1)
<li>test</li> (2)
<li>test</li> (4)<-
<li>test</li> (3)
:last wont do, because the element i added is not the last in the list.
How do i get a reference to (4)?
edit: and please, no eq() solutions, i need this to be dynamic and i can't always know where the element is added in the context.