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

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -