jQuery UI draggable Options stack

Controls CSS z-index of draggable elements, always brings the element that is
being dragged to the front.
$("#eleID").draggable({ stack: ".drag"  });

Try to drag squares sequently, you can see that the one which is being dragged is always in the front.
ExampleJquery ui draggable options stack
Source Code Expand
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.pureexample.com/js/lib/jquery.ui.touch-punch.min.js"></script>


<!-- CSS -->
<style type="text/css">
.drag {
    width: 100px;
    height: 100px;
    line-height: 100px;
    border: 1px solid black;
    cursor: pointer;
    border-radius: 10px;
    text-align: center;
    background-color: lightpink;
    position: relative;
}

.container {
    background-color: lightblue;
    width: 500px;
    height: 400px;
    border: 1px solid black;
    float: left;
    margin-right: 30px;
}
</style>


<!-- Javascript -->
<script>
    $(function () {
        $(".drag").draggable({            
            stack: ".drag"
        });
    });
</script>

<!-- HTML -->
<div id="drag1" class="drag" style="left:20px;top:20px;background-color:orange">drag me 1</div>
<div id="drag2" class="drag" style="left:30px;top:-5px;background-color:lightblue">drag me 2</div>
<div id="drag3" class="drag" style="left:20px;top:-30px;background-color:lightpink">drag me 3</div>


comments powered by Disqus