Skip to content

Instantly share code, notes, and snippets.

@jacksonfdam
Created June 1, 2012 16:29
Show Gist options
  • Save jacksonfdam/2853366 to your computer and use it in GitHub Desktop.
Save jacksonfdam/2853366 to your computer and use it in GitHub Desktop.
jQuery Set DOM Element to Top View Z-Index
jQuery.fn.mb_bringToFront= function(zIndexContext){
  var zi=1;
  var els= zIndexContext && zIndexContext!="auto" ? $(zIndexContext): $("*");
  els.not(".alwaysOnTop").each(function() {
    if($(this).css("position")!="static"){
      var cur = parseInt($(this).css('zIndex'));
      zi = cur > zi ? parseInt($(this).css('zIndex')) : zi;
    }
  });
  $(this).not(".alwaysOnTop").css('zIndex',zi+=1);
  return zi;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment