html - how to add single parent element for all the child nodes in jquery -


i have below code working fine. but, on this, when click first element [node 1], then, copied target div without parent 'ul'. same happening when click child node directly. mean, if click node 1.1, node 1.2 etc, then, these should captured inside single 'ul' element. i.e.,

this below should changed

`<li><span>node 1.1</span></li><li><span>node 1.2</span></li>`  

(this getting right now)

<ul><li><span>node 1.1</span></li><li><span>node 1.2</span></li></ul> 

the same should happen if select 'node 1' also.

any idea? please help.

http://jsfiddle.net/fjalsnlh/7/ kindly make amendments on fiddle link please.

use jquery's wrapall

$('li').wrapall('<ul></ul>'); 

jsfiddle: http://jsfiddle.net/fjalsnlh/12/


Popular posts from this blog

javascript - Js, document.getElementById("ID").innerHTML, error -

jquery - jqGrid update specific column data with out refreshing the entire column? -

objective c - Is there a way in OCMockito to make stubs fail when an unknown method is called? -