0
我使用JQueryUI可拖动,并且想要选择当多个堆叠在一起时(一个在另一个之上)拖动哪个可拖动元素。随着JQueryUI Draggable,如何选择可拖动元素时,分层拖动
我应该在“开始”方法内做些什么吗?
$(".draggable").draggable({
start: function(event, ui) {
// Is there a way I can select to drag #e2:
// so I can use program logic to select which draggable I want to get dragged
}
});
.draggable {
position: absolute;
left: 0px;
top: 0px;
width: 100px;
height: 100px;
opacity: 0.5;
font-size: 50px;
line-height: 100px;
text-align: center;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div class="draggable" id="e1" style="background-color: red">1</div>
<div class="draggable" id="e2" style="background-color: green">2</div>
<div class="draggable" id="e3" style="background-color: blue">3</div>
我还粘贴的jsfiddle较简单的测试: Jquery UI stacked (layered) draggables