admin管理员组文章数量:1241086
I have an ordinary ul li. I want to attach an li to the list which is based on the first li in the list.
html
<div id="gallery">
<ul>
<li>Point Nr 1<p>lol</p></li>
<li>Point Nr 2</li>
<li>Point Nr 3</li>
<li>Point Nr 4</li>
</ul>
</div>
pseudo javascript/jquery
$("#gallery ul li").first().duplicate(attachTo:"#gallery ul li")
This is what it looks like:
<div id="gallery">
<ul>
<li>Point Nr 1<p>lol</p></li>
<li>Point Nr 2</li>
<li>Point Nr 3</li>
<li>Point Nr 4</li>
<li>Point Nr 1<p>lol</p></li>
</ul>
</div
How do I do this? :)
I have an ordinary ul li. I want to attach an li to the list which is based on the first li in the list.
html
<div id="gallery">
<ul>
<li>Point Nr 1<p>lol</p></li>
<li>Point Nr 2</li>
<li>Point Nr 3</li>
<li>Point Nr 4</li>
</ul>
</div>
pseudo javascript/jquery
$("#gallery ul li").first().duplicate(attachTo:"#gallery ul li")
This is what it looks like:
<div id="gallery">
<ul>
<li>Point Nr 1<p>lol</p></li>
<li>Point Nr 2</li>
<li>Point Nr 3</li>
<li>Point Nr 4</li>
<li>Point Nr 1<p>lol</p></li>
</ul>
</div
How do I do this? :)
Share Improve this question asked Dec 20, 2010 at 7:44 TomkayTomkay 5,16021 gold badges65 silver badges94 bronze badges2 Answers
Reset to default 12I think it should be
var ul = $('#gallery ul'); ul.find('li:first').clone(true).appendTo(ul);
Should be:
var $gallery = $('#gallery');
$gallery.find('li:first').clone(true).appendTo($gallery.find('ul'));
Example: http://www.jsfiddle/4yUqL/22/
Ref.: .clone()
本文标签: javascriptJQueryHow to Duplicate ltligt and put it to the end of the ltulgtStack Overflow
版权声明:本文标题:javascript - JQuery - How to: Duplicate <li> and put it to the end of the <ul> - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740090884a2223981.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论