Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
84
rated 0 times [  86] [ 2]  / answers: 1 / hits: 20483  / 13 Years ago, thu, may 26, 2011, 12:00:00

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?


More From » php

 Answers
6

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>
'


[#92031] Wednesday, May 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chase

Total Points: 78
Total Questions: 106
Total Answers: 93

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
chase questions
Thu, Mar 31, 22, 00:00, 2 Years ago
Thu, Jul 1, 21, 00:00, 3 Years ago
Sat, Dec 12, 20, 00:00, 4 Years ago
Mon, Sep 14, 20, 00:00, 4 Years ago
;