javascript - jQuery get all descendant nodes including text nodes -


is there way in jquery descendant nodes of parent node, including text nodes, recursively? know $.contents() method, jquery documentation states:

the .contents() method allows search through immediate children of these elements in dom tree

my problem is, have child node contains more (non-text) nodes, , need instead of parent. trying workaround now:

var contents = container.contents(); var foo = $('.foo'); var index = contents.index(foo); contents.splice(index,1,$('.foo').contents()); 

...but inserts array instead of individual elements. final step pushing elements contents array 1 bone, i'd know if there better way this.

i don't understand trying in order all descendant nodes of element may use following:

var nodes = $('*', container).addback().contents(); 

demo: http://jsfiddle.net/5vfbg/


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -