function colorRandom1(){
var r = Math.floor(Math.random()*51+200);
var g = Math.floor(Math.random()*51+200);
var b = Math.floor(Math.random()*51+200);
return ‘rgb(‘+r+‘,‘+g+‘,‘+b+‘)‘;
}
var div = document.body.getElementsByTagName(‘div‘)[0];
div.style.background = colorRandom();
div.setAttribute(‘style‘,‘color:‘+colorRandom()+‘;background:‘+colorRandom() );
原文地址:http://11990649.blog.51cto.com/11980649/1854971