Chrome中的document.getElementById().innerText [英] document.getElementById().innerText in Chrome
问题描述
设置文本框的值时,快速跨浏览器JS问题:
Quick Cross Browser JS question, when setting the value of a textbox:
document.getElementById("balanceText").innerText = "111";
和
document.getElementById("balanceText").value = "111";
两个工作都在IE中盛行,
Both Work grand in IE,
但是它们不能在Chrome,FF,Opera或Safari中工作.
But they will not work in Chrome, FF, Opera or Safari.
是否有其他方法可以在这些浏览器中使用?
Is there an alternate method that will work in these browsers ?
推荐答案
在其他所有支持JS的重要浏览器中,document.getElementById("balanceText").value = "111";
都相等.
All else being equal document.getElementById("balanceText").value = "111";
works fine in every significant* browser that supports JS.
请确保您只有一个元素带有id="balanceText"
,并且实际上将其作为 id 而不是名称.
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.
*
您不关心NS 4吗?
*
you don't care about NS 4 do you?
这篇关于Chrome中的document.getElementById().innerText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!