I'm using jQuery on an app I've been developing. Let's say I have an unorded list like this...
Then, lets say I have a variable called 'newPosition' whose value is numeric and comes from somewhere else (it doesn't matter where).
I basically want to put a new element into my #animals list so that it is positioned based on the value of the newPosition variable and that of the 'rel' attributes. So, in the example above, if newPosition = 15 then the new element (an li) should be placed between cat and dog.
I have this loop to loop through each li...
relValue = $(this).attr("rel");
So... when the loop comes around to the right psoition how can I add a new element into the list?