var div=document.getElementsByTagName("div");//獲取html的div元素,總共四個??? function vs(a,b){??????? a=document.createElement("div");創建一個div作為body的子元素,且用了絕對定位,距左邊的邊距為變量b??????? document.body.appendChild(a);??????? a.style="position:absolute";??????? a.style.left=b;??????? a.style.top="10px";??????? return a;??? }??? var c=40;//遍歷在四個div的鼠標懸浮事件,可是距左邊的距離我設置的是一直變化的,可是顯示出來卻沒有發生變化,不知是什么原因?????????? for(var i=0;i<4;i++){??????????? div[i].onmouseover=function(){?????????????? this.style.backgroundColor="yellow";?????????????? var b=vs("my",c+c*i+"px");?????????? }??? }
再請教一個問題,關于鼠標事件。。。。。。
慕粉3926413
2016-09-11 10:17:08