I have a scenario similar to this:
<div class="DivParent">
<div class="Child1"></div>
<div class="Child2"></div>
<div class="Child3"></div>
</div>
I want an HTMLObject of Child1, Child2, and Child3 w/o the DivParent parent.
If I was using jQuery I could say:
var HTMLObjectIWant = $('.Parent > div').unwrap();
But I'm not ... I'm using Dojo and I would love to see this done in Dojo. Also- the order (Child1, Ch开发者_开发知识库ild2, Child3 is very important).
Thanks in advance.
-Mike
dojo.unwrap = dojo.unwrap || function(/* node ID or node */ n) {
var node = dojo.byId(n).parentNode;
dojo.query(' > *', node).forEach(function(childNode) {
dojo.place(childNode, node, 'before');
});
dojo.destroy(node);
}
You'll probably want to neaten this up, for example currently it throw an error if n is undefined.
精彩评论