Question

http://jsfiddle.net/HKhw8/67/

HTML:

<p>You can see this text... <span id="text"></span></p>
<p>...but not this: <span id="mathStuffs"></span></p>
<p>Number variables don't seem to show, either- <span id="num"></span></p>

JavaScript:

var text = 'Hello'
var i = 50;
document.getElementById('text').innerHTML = text;
document.getElementById('mathStuffs').innerHTML = math.pow(5,2);
document.getElementById('number').innerHTML = i;

The code doesn't show up in the preview like some of the nicely color-coded syntax highlighting like I've seen in previous posts- sorry about that.

I originally thought that console.log() was the problem, so I have this example set up. Regular text variables show up, but I can't seem to get the numbers or functions that return numbers to appear. Is there something I'm doing wrong? I've tried fiddling with the No wrap - in setting, but I can't understand. I've tried Chrome and FF.

Was it helpful?

Solution

math is not a class of javascript it should be Math

document.getElementById('mathStuffs').innerHTML = Math.pow(5,2);

Also one of the reference of a div is wrong

document.getElementById('number').innerHTML = i;

it should be num

 document.getElementById('num').innerHTML = i;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top