How can I combine multiple uls into one ul?
For example how can i Combine the following.
<ul>
<li>one</li>
<li>two</li>
</ul>
<ul>
<li>three</li>
</ul>
<ul>
<li>four</li>
</ul>
<ul>
<li>five</li>
</ul>
To something like this
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
</ul>
The great thing about
.append()and.appendTo()is that they will move existing DOM elements instead of copying them as you might expect:Customize the
'ul'selector as needed; I recommend using a common class instead of a general tag selector.http://jsfiddle.net/j76Lu/
Slightly more optimized (thanks, adeneo):
http://jsfiddle.net/j76Lu/1/
or even better:
http://jsfiddle.net/j76Lu/2/