自动生成100个li
span{width:30px;height:30px;background: yellow;position: absolute;display: inline-block;}
#div1{width:350px;height:1000px;background: none;border:1px solid red;}
window.οnlοad=function(){ //window.onload必须写
var btn=document.getElementById('btn');
var span=document.getElementsByTagName('span');
var div1=document.getElementById('div1');
btn.οnclick=function(){
for(var i=0;i<100;i++){
div1.innerHTML+=''+ i +'';
}
for(var i=0;i<100;i++){
if(i%10==0){
span[i].style.left=10+i*40+"px"+'
';
}else {
span[i].style.left=10+i*40+"px";
}
}
}
//每10个换行
}
点击变化