div.style.left=Math.floor(Math.random()*500)+‘px’;
后面一定要加上 px
setInterval(function(){
var div=document.createElement(‘div’);
div.setAttribute(‘class’,‘sdiv’);
div.style.left=Math.floor(Math.random()*500)+‘px’;
div.style.top=Math.floor(Math.random()*500)+‘px’;
wrap.appendChild(div);
},100)
随机生成 食物