Reputation: 11
document.getElementById("boxoffice[0][total]").innerHTML = "Working";
function totaltest() {
document.getElementById("boxoffice[0][total]").innerHTML = "Not Working";
}
For some reason, the above innerHTML works perfectly OUTSIDE a function, but not inside...any ideas as to the cause??
Upvotes: 1
Views: 671
Reputation: 31841
Are you sure that you're calling totaltest()
, because the code that you've posted is completely valid.
See the following code, it works fine:
document.getElementById("aa").innerHTML = "test 1";
function totaltest() {
document.getElementById("bb").innerHTML = "test 2";
}
totaltest();
<p id="aa"></p><br>
<p id="bb"></p>
Upvotes: 3
Reputation: 1159
You should do
document.getElementById("boxoffice[0][total]").innerHTML = "Working";
function totaltest() {
document.getElementById("boxoffice[0][total]").innerHTML = "Not Working";
}
totaltest()
its not working because you are not invoking totaltest
Upvotes: 1