Last active
August 18, 2016 15:39
-
-
Save aurbano/9ce7e689d8138f341aea to your computer and use it in GitHub Desktop.
jQuery Draggable bring to front
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$('.drag').bind('click',function(){ bringFront($(this), '.drag'); }); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bringFront(elem, stack){ | |
// Brings a file to the stack front | |
var min, group = $(stack); | |
if(group.length < 1) return; | |
min = parseInt(group[0].style.zIndex, 10) || 0; | |
$(group).each(function(i) { | |
this.style.zIndex = min i; | |
}); | |
if(elem == undefined) return; | |
$(elem).css({'zIndex' : min group.length}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Couple of sections where operators are missing, I added the + sign and works like charm.
Browser threw errors at Lines 8 and 12. Also I changed from 'click' to 'mousedown', the result being that your code would not change the z-Index until I released the mouse button, but this one does.
Commend your JS script, saved me a lot of headaches!