Adding a line in javascript code

reidjako
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

Niet the Dark Absol

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Adding a line in javascript code

From Dev

Magic Line CSS/Javascript code - Adding sub navigation

From Dev

Magic Line CSS/Javascript code - Adding sub navigation

From Dev

SVG - Adding a line with Javascript

From Dev

Adding images to Javascript Code

From Dev

Adding javascript code in iframe.

From Dev

NuGet: Possibility of adding a line of code via Powershell?

From Dev

Adding a line break in JavaScript (full calendar)

From Dev

adding line break into javascript from php

From Dev

Javascript Adding line break before "-" and after "."

From Dev

adding line break into javascript from php

From Dev

Python : Adding a code routine at each line of a block of code

From Dev

Javascript line of code in plain english

From Dev

The interpretation of one line Javascript code

From Dev

Why is there an error on this line of Javascript code?

From Dev

Please explain this line of javascript code

From Dev

Debugging JavaScript & css code: adding an event handler

From Dev

Simplifying Jquery/Javascript code and adding animation

From Dev

Adding a line in a method block of java code using python

From Dev

tcl - Adding comments around a single line in code (for blocking): Use of regex

From Dev

Adding/removing some tabs and line breaks in an HTML code using sed

From Dev

Android app keeps crashing after adding a specific line of code

From Dev

Remove new line in javascript code in string

From Dev

Convert a javascript one line in more readable code

From Dev

only the first line of my javascript code works

From Dev

Countdown Timer Javascript In Line Code External Scripts

From Dev

How to reformat code, adding a new line before a line separator "\n in PhpStorm?

From Dev

Adding pure javascript code to Shopify Theme by using Shopify API

From Dev

Adding code to a javascript module pattern from an outside file

Related Related

  1. 1

    Adding a line in javascript code

  2. 2

    Magic Line CSS/Javascript code - Adding sub navigation

  3. 3

    Magic Line CSS/Javascript code - Adding sub navigation

  4. 4

    SVG - Adding a line with Javascript

  5. 5

    Adding images to Javascript Code

  6. 6

    Adding javascript code in iframe.

  7. 7

    NuGet: Possibility of adding a line of code via Powershell?

  8. 8

    Adding a line break in JavaScript (full calendar)

  9. 9

    adding line break into javascript from php

  10. 10

    Javascript Adding line break before "-" and after "."

  11. 11

    adding line break into javascript from php

  12. 12

    Python : Adding a code routine at each line of a block of code

  13. 13

    Javascript line of code in plain english

  14. 14

    The interpretation of one line Javascript code

  15. 15

    Why is there an error on this line of Javascript code?

  16. 16

    Please explain this line of javascript code

  17. 17

    Debugging JavaScript & css code: adding an event handler

  18. 18

    Simplifying Jquery/Javascript code and adding animation

  19. 19

    Adding a line in a method block of java code using python

  20. 20

    tcl - Adding comments around a single line in code (for blocking): Use of regex

  21. 21

    Adding/removing some tabs and line breaks in an HTML code using sed

  22. 22

    Android app keeps crashing after adding a specific line of code

  23. 23

    Remove new line in javascript code in string

  24. 24

    Convert a javascript one line in more readable code

  25. 25

    only the first line of my javascript code works

  26. 26

    Countdown Timer Javascript In Line Code External Scripts

  27. 27

    How to reformat code, adding a new line before a line separator "\n in PhpStorm?

  28. 28

    Adding pure javascript code to Shopify Theme by using Shopify API

  29. 29

    Adding code to a javascript module pattern from an outside file

HotTag

Archive