var run=function(){
$("#imagesbox div").each(function(index,val){
var width=Math.floor(Math.random()*10);
$(this).css('width',a[width]);
$(this).css('background-color',b[width]);
$("#imagesbox img").mousedown(function(e){
e.stopPropagation();
if(e.button==0){
console.log("left");
a.map(function(ele){
return ele-20;
})
}else if(e.button==2){
console.log("right");
a.map(function(ele){
return ele+20;
})
}
})
console.log(a[width]);
})
}
var time=setInterval(run,1000)
$("#imagesbox div").each(function(index,val){
var width=Math.floor(Math.random()*10);
$(this).css('width',a[width]);
$(this).css('background-color',b[width]);
$("#imagesbox img").mousedown(function(e){
e.stopPropagation();
if(e.button==0){
console.log("left");
a.map(function(ele){
return ele-20;
})
}else if(e.button==2){
console.log("right");
a.map(function(ele){
return ele+20;
})
}
})
console.log(a[width]);
})
}
var time=setInterval(run,1000)
run();
以下方法:
var a=[200,210,220,230,240,250,260,270,280,190,180];
var b=["red","blue","yellow","#39f","gray","white","green"]
var time=setInterval('run()',1000)
var run=function(){
$("#imagesbox div").each(function(index,val){
var width=Math.floor(Math.random()*10);
$(this).css('width',a[width]);
$(this).css('background-color',b[width]);
$("#imagesbox img").mousedown(function(e){
e.stopPropagation();
if(e.button==0){
console.log("left");
a.map(function(ele){
return ele-20;
})
}else if(e.button==2){
console.log("right");
a.map(function(ele){
return ele+20;
})
}
})
console.log(a[width]);
})
}
run();