Javascript 如何让两个DIV';如果在某个区域,s会自动相互连接吗?
只是在寻找想法而已。我想要的是当两个有图像的div彼此靠近时,移动它们的位置以相互连接。你知道怎么做吗 HTMLJavascript 如何让两个DIV';如果在某个区域,s会自动相互连接吗?,javascript,html,Javascript,Html,只是在寻找想法而已。我想要的是当两个有图像的div彼此靠近时,移动它们的位置以相互连接。你知道怎么做吗 HTML <body onkeyup="clearPress()" onkeydown="controlCheck(event)" style="cursor: auto;"> <div id="application" style="position:absolute"> <div id="accordion" class="ui-acc
<body onkeyup="clearPress()" onkeydown="controlCheck(event)" style="cursor: auto;">
<div id="application" style="position:absolute">
<div id="accordion" class="ui-accordion ui-widget ui-helper-reset" style="position:absolute;top:0px;left:0px;width:300px;height:900px" role="tablist"> … </div>
<div id="buttons" style="position:absolute;top:0px;left:315px;width:1100px;height:50px;border:2px solid grey;background: url('images/ui-bg_glass_75_e6e6e6_1x400.png') repeat-x scroll 50% 50% rgb(230, 230, 230);"> … </div>
<div id="canvas" class="DROPPABLE ui-droppable" style="position:absolute;top:50px;left:315px;width:1100px;height:850px;border:2px solid grey">
<div class="DRAGGABLE ui-draggable" style="position: absolute; width: 120px; height: 60px; top: 123.817px; left: 507.7px;" onclick="addBorder(this)">
<img id="PMF00" src="/devices/AAU01-010.gif"></img>
</div>
<div class="DRAGGABLE ui-draggable" style="position: absolute; width: 42px; height: 42px; top: 988.7px; left: -344.3px;" onclick="addBorder(this)"> … </div>
<div class="DRAGGABLE ui-draggable" style="position: absolute; width: 84px; height: 36px; top: 138.7px; left: 412.467px;" onclick="addBorder(this)"> … </div>
<div class="DRAGGABLE ui-draggable" style="position: absolute; width: 80px; height: 41px; top: 143.7px; left: 151.7px;" onclick="addBorder(this)"> … </div>
<div class="DRAGGABLE ui-draggable" style="position: absolute; width: 100px; height: 100px; top: 92px; left: 344px;" onclick="addBorder(this)"> … </div>
</div>
</div>
…
…
…
…
…
…
Snap是我一直在寻找的词,我将Snap设置为true,它可以工作,谢谢 使用指定的捕捉选项初始化可拖动文件:
$( ".selector" ).draggable({ snap: true });
初始化后,获取或设置快照选项:
// getter
var snap = $( ".selector" ).draggable( "option", "snap" );
// setter
$( ".selector" ).draggable( "option", "snap", true );
你是说,拖动后将它们捕捉到位?