HTML:<div id=box> <img src="images/psb.jpg" alt="师大光影" id="img1"/> <img src="images/psb.jpg" alt="师大光影" id="img2"/> <div id=main> <div id="left-up" class="minDiv left-up"></div> <div id="upDiv" class="minDiv up"></div> <div id="right-up" class="minDiv right-up"></div> <div id="leftDiv" class="minDiv left"></div> <div id= rightDiv class="minDiv right"></div> <div id="left-bottom" class="minDiv left-bottom"></div> <div id="downDiv" class="minDiv bottom"></div> <div id="right-bottom" class="minDiv right-bottom"></div> </div>js代码:mainDiv.ommousedown=function(){ var boxDiv=document.getElementById("box"); var mainDiv=document.getElementById("main"); boxDiv.onmousemove= function(event){ event=event||window.event; var x=event.clientX; var y=event.clientY; mainDiv.style.top=y+"px"; mainDiv.style.left=x+"px"; } }
添加回答
举报
0/150
提交
取消