代码看起来像document.getElementById.a = 1
. 这在 IE 中除外。正如文件所说
该函数也是一个对象
所以它可以添加属性,对吧?
尝试使用方法setAttribute
即
document.getElementById('<IDofElement>').setAttribute('a',1);
You can add 'a' to Function prototype. Then it will be available for all Functions.
Function.prototype.a = 1;
console.log(document.getElementById.a); //logs 1
console.log(document.getElementsByClassName.a); //also logs 1
This is not the best solution, but should work even on IE.