3
I managed to create the new div
at the end of div
id pai
with .appendChild
:
<div id="pai">
<div id="filho1">texto qualquer 1</div>
<div id="filho2">texto qualquer 2</div>
<div id="filho3">texto qualquer 3</div>
</div>
<script>
var nova_div = document.createElement('div');
nova_div.innerText = 'NOVA DIV';
document.getElementById('pai').appendChild(nova_div);
</script>
But I wanted her among the others div
, instead of at the end.
Example:
<div id="pai">
<div id="filho1">texto qualquer 1</div>
<div id="filho2">texto qualquer 2</div>
<div>NOVA DIV</div>
<div id="filho3">texto qualquer 3</div>
</div>
How can I do?
The prepend does what you need. No link has a polyfill for IE.
– DaviAragao
I tried with this function, but it goes to the end as appendchild and I want to enter. But I already got with the function of Sam vlw!!
– Zer0