*jquery库去我的下载里面下载

===============================================================//监听事件与回显

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script><scriptsrc="jquery-ui-1.8.16.custom.min.js"type="text/javascript"></script><scripttype="text/javascript">//监听事件与回显$(function(){$("#dragsource").draggable({create:function(event,ui){$("#div1").html("创建了");},start:function(event,ui){$("#div1").html("拖动了");},drag:function(event,ui){$("#div1").html("移动中");},stop:function(event,ui){$("#div1").html("停止了");},revert:"invalid",//拖动返回原来的位置cursor:"move"//拖动时的样式});//可拖动DIV$("#droppalbe").droppable({create:function(event,ui){$("#div2").html("创建了");},activate:function(event,ui){$("#div2").html("activeta");},//判断源div能不能落到目标div上(拖拽中)deactivate:function(event,ui){$("#div2").html("deactivate");},//判断源div能不能落到目标div上(拖拽停止)over:function(event,ui){$("#div3").html("进入容器");},out:function(event,ui){$("#div3").html("离开容器");},drop:function(event,ui){$("#div3").html("落到容器上了");}//和activate、deactivate有冲突});//容器});</script></head><body><divid="dragsource"><p>拽我!</p></div><divid="droppalbe"><p>Drophere</p></div><divid="div1"></div><divid="div2"></div><divid="div3"></div></body></html>

===============================================================//复制拖动(helper)

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script><scriptsrc="jquery-ui-1.8.16.custom.min.js"type="text/javascript"></script><scripttype="text/javascript">//复制拖动$(function(){$("#resource").draggable({helper:"clone"});$("#targer").droppable({drop:function(event,ui){//把源div放在容器中时触发vardiv=$("#resource").clone(false);//复制divdiv.css({"top":ui.offset.top+"px","left":ui.offset.left+"px"});//设置坐标$(this).append(div);//在容器中添加div}});});</script></head><body><div></div><div><divid="resource"></div></div><divid="targer"></div></body></html>

===============================================================//拖动方向控制(axis)

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script><scriptsrc="jquery-ui-1.8.16.custom.min.js"type="text/javascript"></script><scripttype="text/javascript">$(function(){//拖动方向控制$("#resouce").draggable({//axis:"x"//限制x轴移动axis:"y"//限制y轴移动});});</script></head><body><divid="resouce"></div></body></html>

===============================================================//拖动范围控制(containment)

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script><scriptsrc="jquery-ui-1.8.16.custom.min.js"type="text/javascript"></script><scripttype="text/javascript">//拖动范围控制$(function(){$("#resource").draggable({//containment:$("#targer")第一种方式//containment:"parent"第二种方式containment:[0,0,300,200]//第三种方式});});</script></head><body><divid="targer"><divid="resource"></</div>div></body></html>

===============================================================//拖动吸附(snap,grid)

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script><scripttype="text/javascript"src="jquery-ui-1.8.16.custom.min.js"></script><scripttype="text/javascript">$(function(){//拖动吸附$("#source1").draggable({snap:true});$("#source2").draggable({snap:"#targer"});$("#source3").draggable({grid:[50,50]});});</script></head><body><divid="targer">容器</div><br/><br/><br/><divid="source1">吸附到可拖动div</div><br/><br/><br/><divid="source2">吸附到容器</div><br/><br/><br/><divid="source3">吸附到网格</div></body></html>

===============================================================//拖动div手柄(handle)

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><title></title><scriptsrc="jquery-1.4.2.min.js"type="text/javascript"></script><scriptsrc="jquery-ui-1.8.16.custom.min.js"type="text/javascript"></script><scripttype="text/javascript">$(function(){//拖动div手柄$("#resource").draggable({handle:$(".p")});});</script></head><body><divid="resource"><pclass="p"></p></div></body></html>