jquery实现可移动层
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(function(){
$("#gb").mousedown(function(e){
var offset = $("#moveDiv").offset();
var p = {top:offset.top - e.clientY,left:offset.left - e.clientX};
if (!e) e = window.event;
$(document).mousemove(function(e){
$("#gb").css("cursor","text");
$("#moveDiv").css({"top":e.clientY + p.top,"left":e.clientX + p.left});
});
$(document).mouseup(function(){
$("#gb").css("cursor","move");
$(this).unbind("mousemove");
});
});
});
</script>
</head>
<body>
<div id="moveDiv" style="width:100px;height:100px;position:absolute;border:1px solid #CCCCCC;background:#FFFFFF">
<div id="gb" style="text-align:right;background:#CCCCCC;width:100%;cursor:move;"><a href="#">关闭</a></div>
</div>
</body>
</html>