[英]Appending after an element in jQuery
I'm using jQuery in my current project. 我在当前项目中使用jQuery。 I have an list of elements with unique ids.
我有一个具有唯一ID的元素列表。 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. 我想在ID为1的列表项后附加
<li id="two">two</li>
。
Thanks. 谢谢。
$('ul #one').after('<li id="two">two</li>');
使用富有想象力的after方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.