日期:2014-05-16 浏览次数:20409 次
<div id="grid"></div>
<script type="text/javascript">
console.time("scs");//统计时间
function dealEvent(obj,evt,fun){
obj.addEventListener ? obj.addEventListener(evt,fun,false) : obj.attachEvent("on"+evt,fun);
}
function Handler(e){ e = e
------解决方案--------------------
window.event;}
var picSize=50,rMax=cMax=100,frame = document.createDocumentFragment();
for (var r=0;r<rMax;r++){
for (var c=0;c<cMax;c++){
var div=document.createElement("li");
div.id=parseInt((r*rMax)+c);
dealEvent(div,"click",Handler);
div.style = "position:absolute;background-color: green;top:"+r*picSize+"px;left:" +c*picSize+"px;width:" +picSize+"px;height:"+picSize+"px;";
frame.appendChild(div);
}
}
document.getElementById("grid").appendChild(frame);
console.timeEnd("scs");//大概花费161MS 挺快呀!
</script>