<body><div id="box">鼠标移入移出变色</div><script>var box = document.getElementById("box");
box.onmouseover=function(ev){var a = Math.floor(Math.random()*256);var b = Math.floor(Math.random()*256);var c = Math.floor(Math.random()*256);
box.style.backgroundColor ="rgb("+ a +","+ b +","+ c +")"}
box.onmouseout=function(ev){var a = Math.floor(Math.random()*256);var b = Math.floor(Math.random()*256);var c = Math.floor(Math.random()*256);
box.style.backgroundColor ="rgb("+ a +","+ b +","+ c +")"}</script></body>