Javascript getElementbyId不是函数
我有一个简单的JavaScript,它可以改变按钮的颜色,但我一直得到这样一个错误:获取按钮不是一个函数,即使同一个函数(具有相同的大写和大小写)只在上面几行中起作用Javascript getElementbyId不是函数,javascript,Javascript,我有一个简单的JavaScript,它可以改变按钮的颜色,但我一直得到这样一个错误:获取按钮不是一个函数,即使同一个函数(具有相同的大写和大小写)只在上面几行中起作用 if (this.ButtonColor != "") { var button = document.getElementbyId('modal-close'); button.style.backgroundColor = this.ButtonColor; } 函数是document.getEle
if (this.ButtonColor != "") {
var button = document.getElementbyId('modal-close');
button.style.backgroundColor = this.ButtonColor;
}
函数是
document.getElementById()
,而不是document.getElementById()
函数是document.getElementById()
,而不是document.getElementById()
这只是一个打字错误,您要找的函数是getElementById
。
By用大写B代替By
是对该方法的引用。这只是一个输入错误,您要查找的函数是
getElementById
。
By用大写B代替By
是对该方法的引用。而不是使用此。按钮颜色您尝试过吗
var button = document.getElementById("modal-close");
button.style.backgroundColor = "the color you want rather than using "
不是用这个。按钮颜色,你试过了吗
var button = document.getElementById("modal-close");
button.style.backgroundColor = "the color you want rather than using "
document.getElementById('modal-close')
document.getElementById('modal-close')代码>