+ 2
Is there something im missing about the "document.getElementById().innerHTML"
some how when i started i said this was going to be easy because ive done it multiple times in my money counter but when i try a simple code like this one below it seems to be having an output error which is making me irritated over this simple objective that is very very basic so im gonna ask for help even though its gonna make me look like a fool maybe im missing something but anyway all i want is the output to display https://code.sololearn.com/WoYSIEgOB7EQ/?ref=app
7 Answers
+ 10
The problem here is that your script executes before the document loads. Fix this by wrapping your script in a function and calling it after the document loads.
window.onload = function(){
var so1=0.07 * 16;
var so1a=so1 + 1.25;
var so1b=so1a.toFixed(2);
document.getElementById("so1c").innerHTML = so1b;
}
+ 8
this seemed to work for me
window.onload = function(){
// your javascript code
}
putting this makes sure the document is completely loaded before you can manipulate the elements, otherwise you could be setting the inner HTML of an element that doesn't exist (not loaded yet)
+ 4
you can discuss it on this app in a sololearn server (group chat)
https://www.sololearn.com/discuss/689391/?ref=app
+ 2
thank you so much spend about an hour and a half trying to figure whats wrong or what i did wrong
0
hi
0
Hey Guys I need help with an assignment for school
0
html
ob = document.getElementById("
");
.innerHTML = "Hi";
help