开发者

Copying children of a <ul> to another <ul> using jQuery

How can I copy copy content of a ul that is li's inside it to开发者_开发百科 another ul.

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


You can .clone() the children then use .appendTo() to put them on the destination <ul>, like this:

$("#source").children().clone().appendTo("#target");


s.children().clone().appendTo(t)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜