I have the following structure:
<div class="parent">
<div id="child1">Content here</div>
<div class="child2">Content here</div>
</div>
At onload, I want to include a "holder" div, that holds all the parent's children like so:
<div class="parent">
<div id="holder">
<div id="child1">Content here</div>
<div class="child2">Content here</div>
</div>
</div>
Knowing only the "child1" id, how can I add a holder div around itself and siblings?
Considerations
- The "child1" id is the only known identifier.
- The class "parent" and "child2" are dynamic name and will change, so can't be used as identifiers.
- needs to be vanilla JavaScript.
Thoughts?