0

I am having some issues changing the HTML via the "innerHTML" command .... I have success changing it with simple things like "Hello" or even a series of strings added together, but when I put in the entire HTML I want it breaks my program....I loooked and looked for missing syntax but am at a loss

document.getElementById("results").innerHTML = 

   "<h1 class=\"bold\">Results</h1>
     <table>
        <tr>
           <th>Starting Bet</th>
           <th>" + initialBet + "</th>
        </tr>
        <tr>
           <td>Total Rolls Before Going Broke</td>
           <td>"+n+"</td>
        </tr>
        <tr>
           <td>Highest Amount Won</td>
           <td>"+maxMoney+"</td>
        </tr>
        <tr>
           <td>Roll Count at Highest Amount Won</td>
           <td>"+rollsMaxMoney+"</td>
        </tr>
     </table>";
Adam
  • 325
  • 2
  • 7
  • 1
    Remove newlines in the string OR add `\\` at the end of each newline OR use template string/backticks – Tushar Apr 13 '16 at 03:43
  • 1
    As @Tushar indicated, you can't put literal line breaks in a JavaScript string literal. You have to escape them or build the string with concatenation. – elixenide Apr 13 '16 at 03:47

0 Answers0