views:

16

answers:

2

I'm using jQuery in my current project. I have an list of elements with unique ids. I would like to pick out a particular element and append a new list item after that element. For example, if I have something like:

<ul>
    <li id="one">one</li>
    <li id="three">three</li>
</ul>

I would like to append <li id="two">two</li> after the list item with an id of one.

Thanks.

+1  A: 

Use the imaginatively named after method.

David Dorward
+3  A: 
$('ul #one').after('<li id="two">two</li>');
Matt Williamson
I don't know how I missed that in the API. Thanks.
helixed
If that solved your problem, Matt would probably appreciate if you marked the answer as accepted.
Scytale
You have to wait a little bit before it will let you.
helixed
Appreciate it @Scytale
Matt Williamson