Hello I have a div as follows
<div id="test" class="test2">
<p> <a href=""> <a> </p>
<p> <a href=""> <a> </p>
<p> <a href=""> <a> </p>
<p> <a href=""> <a> </p>
</div>
(I have stripped out the data but that is the structure)
How does one use the addChild function of javascript to add a new node
<p> <a href=""> <a> </p>
I know how to use the removeChild function but I haven't been able to find documentation and examples using the addChild function.
If I have the node string in a php array, and can execute the php script containing the array with a GET call via a button click how can I use the addChild function to put the node string into the div?
addChild
is a php function, The javascript function is called appendChild
:
var dv = document.createElement("p");
dv.innerHTML = "<a href=""> </a> ";
document.getElementById('test').appendChild(dv)
Alternativly, you can append the node string to the html:
document.getElementById('test').innerHTML += '<p> <a href=""> <a> </p>
'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With