简体   繁体   中英

Appending after an element in jQuery

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.

$('ul #one').after('<li id="two">two</li>');

使用富有想象力的after方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM