Skip to content

Instantly share code, notes, and snippets.

View catarinavclemente's full-sized avatar
🏠
Working from home

Catarina Clemente catarinavclemente

🏠
Working from home
View GitHub Profile
@catarinavclemente
catarinavclemente / draggable.js
Last active December 13, 2015 19:48
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;