开发者

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

开发者 https://www.devze.com 2023-01-28 01:14 出处:网络
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()

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

精彩评论

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