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.
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.