Copy child <ul> elements to another <ul> using jQuery

How to copy contents of ul contents with li inside it to another ul .

Say we have t = $("ul#target") and s = $("ul#source") .

+6
jquery
source share
2 answers

You can .clone() then use .appendTo() to put them in the <ul> destination, for example:

 $("#source").children().clone().appendTo("#target"); 
+20
source share
 s.children().clone().appendTo(t) 
+2
source share

All Articles