IT Spider
11-05-2003, 05:02 AM
I am trying to update paragraphs from an array of optional text - how do I get any formatting to be included?
\n is seen by the script as it is not printed, but it is not 'linefeeding either!?
function swapPara(theText)
{
var displayedText = document.getElementById("text");
do {
displayedText.removeChild(displayedText.childNodes[0]);
}
while (displayedText.hasChildNodes());
document.getElementById("text").appendChild(document.createTextNode(theText));
}
<a href="swapText('New \n Paragraph')>Change Paragraph</a>
<p id="text">Default<br>Text</p>
Thanks again
Neil
\n is seen by the script as it is not printed, but it is not 'linefeeding either!?
function swapPara(theText)
{
var displayedText = document.getElementById("text");
do {
displayedText.removeChild(displayedText.childNodes[0]);
}
while (displayedText.hasChildNodes());
document.getElementById("text").appendChild(document.createTextNode(theText));
}
<a href="swapText('New \n Paragraph')>Change Paragraph</a>
<p id="text">Default<br>Text</p>
Thanks again
Neil