Is it possible to add something with innerHTML before/after the nth child of <body>
?
e.g.:
<html>
<head></head>
<body>
<div id="first">First</div>
<div id="second">Second<div id="second_sub"></div></div>
<div id="third">Third</div>
</body>
</html>
I can add at the beginning with body.innerHTML = html + body.innerHTML
and at the end with body.innerHTML += html
but how to add, for example, before the second <div>
?
I don't want to use replace on <div id="second">
as the source changes and the insert should be done at random. Is there a solution with innerHTML or do I need to switch to Dom Nodes? Would be slow in old browsers :(