Skip to content

Instantly share code, notes, and snippets.

@catarinavclemente
Last active December 13, 2015 19:48
Show Gist options
  • Save catarinavclemente/4965315 to your computer and use it in GitHub Desktop.
Save catarinavclemente/4965315 to your computer and use it in GitHub Desktop.
Draggable containment using the selector's parent and z-index increment.
$(document).ready (function() {
$("div,img").draggable({ containment: "parent" });
var containment = $( "div,img" ).draggable( "option", "containment" );
$("div,img").draggable( "option", "containment", "parent" );
$(function($){
var sqs = $("div,img").mousedown(function(){
sqs.each(function(){
if(this.style.zIndex > 0){--this.style.zIndex;}
});
this.style.zIndex = 10000;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment