-5

I have a syntax error, but am not sure where. I have no typos and ran an alert as a test and it worked. Also I can use my canvas in my html but not in my external javascript.

HTML:

<div id="inner">
    </div>

JS:

document.getElementById('inner').innerHtml='<canvas id="gameCanvas1" width="800px" height="500px" style="display:block;background:#E6E6E6;margin:100px auto 0px;"></canvas>'
asdfasdf
  • 5
  • 6

2 Answers2

2

Remove the

document.getElementById("inner")

at the start of the line and fix the case in the following GetElementById (which should be getElementById) and in innerHtml (which should really be innerHTML).

And next time, ensure your code is easy to read to avoid this kind of error. This means for example you can read it without horizontal scrollbar.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
0

Modify your JS as below:

document.getElementById("inner").innerHtml='<canvas id="gameCanvas1" width="800px" height="500px" style="display:block;background:#E6E6E6;margin:100px auto 0px;"></canvas>'
user3684675
  • 381
  • 4
  • 8
  • 32