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();
Comments
Post a Comment