0

So I am trying to write a code where it has a pre tag and it turns into another value with multiple lines. Here is my code:

var pre = document.getElementById("text");
pre.innerHTML = "
Line 1
Line 2
Line 3
Line 4
"

When I do this it gives me error:
Uncaught SyntaxError: Invalid or unexpected token The line which gives me the error is

pre.innerHTML = "

1 Answers1

2

Use Template Literals for Mulitline strings

var pre = document.getElementById("text");
pre.innerText = `
  Line 1
  Line 2
  Line 3
  Line 4
`
Dan Starns
  • 3,765
  • 1
  • 10
  • 28
Vasim Hayat
  • 909
  • 11
  • 16