Adding a new list item to the TOP of a UL, and before the last LI
Hey guys,
so to get the point, I want to add a list item to the top of a ul, and in another case above the last li.
The first one really doesn't have a visual aspect to go with it, just adding a new item, the second can be illustrated as:
<ul>
<li>a</li>
--------------------------> On clicking submit, each new LI will go above the subit list item
<li><submit></li>
</ul>
One of the problems Im running into doing it as below is that if there is no list item in the UL above the submit button, it can't do -2 length.
Any and all help would be great, you guys rock!
- var whichLi = $(thisPost).parent().find("ul.replies > li");
- var thisLi = whichLi.eq(whichLi.length-2);