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