How to move an unordered list to a new part on a page in JQuery?
Question
Here's the story. I've got an unordered list inside a div on my page.
The code:
<div id="move-me">
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div>
The above code is positioned on the left of the page, now what I want to do is, destroy the div and ul elements and be only left with the links. Then finally append these links to a sidebar list.
Any ideas?
Solution
OTHER TIPS
You want to remove the links from the LI tags then add to the sidebar then remove the unordered list. Something like this should work:
$('#move-me > a').appendTo('#sidebar'); $('#move-me').remove();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow