一串跟着鼠标的div

一串跟着鼠标的div:
                            window.onload=function(){
                                            var oBox=document.getElementById("box");
                                            var aDiv=oBox.getElementsByTagName('div');
                                            for(var i=0;i<20;i++){    //创建20个div;
                                                    oBox.innerHTML+='<div></div>';
                                            }
                                            document.onmousemove=function(ev){
                                                    var e=ev||event;
                                                    for(var i=aDiv.length-1;i>0;i--){
                                                                aDiv[i].style.left=aDiv[i-1].offsetLeft+'px';//前一个跟着后面的移动
                                                                aDiv[i].style.top=aDiv[i-1].offsetTop+'px';
                                                    }
                                                    aDiv[0].style.left=e.clientX-aDiv[0].offsetWidth/2+'px';//第一个div跟着鼠标移动;
                                                    aDiv[0].style.top=e.clientY-aDiv[0].offsetHeight/2+'px';
                                            }
                                        }

人生如戏,或实力或演技
原文地址:https://www.cnblogs.com/yang0902/p/5698664.html