function calcPrimesLoop() {
var primes = document.getElementById('primes');
primes.appendChild(document.createTextNode(" , /n , "+this.prime.nextPrime()));
calcPrimesDelay = setTimeout('calcPrimesLoop()', this.delay);
}
Okay so this is my code I am displaying an array of prime numbers. The issue is that I want each prime number to be on a seperate line but I am unable to do this. I have tried
/n and
but they have not worked. It is being displayed in a textarea in html. Thank you
You should use a backslash instead of a forward slash (\n
)
EDIT: The below only applies to "normal" elements. For a textarea, you should be doing primes.value += " , \n , "+this.prime.nextPrime();
Additionally, newlines are collapsed in HTML (if you write text on multiple lines in your source code, it comes out on one line) but you can "fix" this using simple CSS:
primes.style.whiteSpace = "pre-wrap";
Spread the word about white-space
! People need to stop using <br />
tags just to get a newline!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments