为什么网站http://xn--wiadomesny-37b.pl/test/引发Uncaught TypeError: Cannot set property 'innerHTML' of null
?为什么JavaScript无法找到给定的InnerHTML并返回无法设置属性'innerHTML'为null?
HTML(http://xn--wiadomesny-37b.pl/test/):
<div class="castle_array" id="2x1" name="2x1"></div>
<div class="castle_array" id="3x1" name="3x1"></div>
<div class="castle_array" id="4x1" name="4x1"></div>
...
的JavaScript(http://xn--wiadomesny-37b.pl/test/B_modeWindow.js):
for (x = 1; x <= 5; x++) {
for (y = 1; y <= 5; y++) {
document.getElementById(x+"x"+y).addEventListener("click",B_modeWindow('1',this.id));
}}
当我改变
("click",B_modeWindow('1',this.id)
到
("click",B_modeWindow('1','string')
它就像一个魅力 - 为什么?
因为JavaScript没有找到它应该显示的元素,所以它正在工作。请发布一个[现场演示](http://jsfiddle.net/),重现问题或您的问题。 –
All all in source –