开发者

document.getElementById().innerText in Chrome

开发者 https://www.devze.com 2023-04-12 04:14 出处:网络
Quick Cross Browser JS question, when se开发者_StackOverflowtting the value of a textbox: document.getElementById(\"balanceText\").innerText = \"111\";

Quick Cross Browser JS question, when se开发者_StackOverflowtting 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 ?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号