动态增加onclick方法为何不行
我代码大概如下:
var newArea = document.createElement( "area ");
newArea.shape = "rect ";
newArea.coords = area.childNodes[0].nodeValue;
newArea.onClick=function(){alert(1);}
newArea.href = "# " ;
imap.appendChild(newArea);
可是click热区却没有反应,请问如何解决,谢谢
------解决方案--------------------Try:
var newArea = document.createElement( "area ");
imap.appendChild(newArea);//最好创建好立即加入DOM
newArea.shape = "rect ";
newArea.coords = area.childNodes[0].nodeValue;
newArea.onclick=function(){alert(1);}//小写
newArea.href = "# " ;