javascript实现可以拖动的层示例(层拖动,兼容IE/FF)时间:2021-07-05 04:01:07帮一朋友临时写的,感觉还算简洁,效果也还不错,记下来,避免下次再造*: 运行一下看看 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">#main div{position:absolute;width:220px;height:150px;border:1px solid #999;}</style></head><body> <div id="main"> <div style="left:100px;top:100px;background:#fc9;" onmousedown="$(this,event)">1</div> <div style="left:400px;top:100px;background:#9cf;" onmousedown="$(this,event)">2</div> <div style="left:700px;top:100px;background:#f9c;" onmousedown="$(this,event)">3</div> <div style="left:100px;top:300px;background:#9fc;" onmousedown="$(this,event)">4</div> <div style="left:400px;top:300px;background:#c9f;" onmousedown="$(this,event)">5</div> <div style="left:700px;top:300px;background:#cf9;" onmousedown="$(this,event)">6</div> </div></body></html>运行一下看看