Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.getElementById().innerText in Chrome

Quick Cross Browser JS question, when setting the value of a textbox:

document.getElementById("balanceText").innerText = "111";

and

document.getElementById("balanceText").value = "111";

Both Work grand in IE,

But they will not work in Chrome, FF, Opera or Safari.

Is there an alternate method that will work in these browsers ?

like image 700
strvanica Avatar asked Oct 10 '11 14:10

strvanica


1 Answers

All else being equal document.getElementById("balanceText").value = "111"; works fine in every significant* browser that supports JS.

Make sure that you have one, and only one, element with id="balanceText" and that it actually has that as its id and not just the name.

* you don't care about NS 4 do you?

like image 163
Quentin Avatar answered Oct 03 '22 04:10

Quentin