Not sure if this should be in the Javascript forum, but here goes....
I've been playing with adding & deleting ChildNodes to Document nodes by ID.
E.G. set a div tag with an ID, then using appendChild to add a paragraph node, using something like this
However I have a couple of questions I can't find an answer to,
1. how do I give the new paragraph an ID so I can then issue style attributes to change font colour, size, etc...
2. document.createTextNode seems to place just text in the paragraph, even if the text you supply is HTML. How do you change the content of a paragraph node with HTML and have the browser interpret the code rather than showing the HTML on the screen as text.
All help is appreciated.
Regards,
1DMF
I've been playing with adding & deleting ChildNodes to Document nodes by ID.
E.G. set a div tag with an ID, then using appendChild to add a paragraph node, using something like this
Code:
var theNewParagraph = document.createElement('p');
var theTextOfTheParagraph = document.createTextNode('Some content.');
theNewParagraph.appendChild(theTextOfTheParagraph);
document.getElementById('someElementId').appendChild(theNewParagraph);
However I have a couple of questions I can't find an answer to,
1. how do I give the new paragraph an ID so I can then issue style attributes to change font colour, size, etc...
2. document.createTextNode seems to place just text in the paragraph, even if the text you supply is HTML. How do you change the content of a paragraph node with HTML and have the browser interpret the code rather than showing the HTML on the screen as text.
All help is appreciated.
Regards,
1DMF