This plugin allows retrieving the maxium zIndex of the document or a set of elements specified. It can also be used to set the zIndex to the max zIndex value plus a provided increment value to force elements to the top of the zOrder.

$.fn.maxZIndex = function(opt)
$.maxZIndex = function(opt)

Note the dual interface that works both as a plugin and utility function of jQuery. The utility function only returns the maximum zIndex value of the page. The plugin function instead is used to set the zIndex value of the selected element(s) to the highest zIndex plus a provided increment value. Effectively it makes the element the top level.


The option parameter can be passed to either version of the plug-in:

The increment over the maximum zIndex found to set the elements z-index style to. Default: 10. Ignored by the utility function that only returns the max zIndex.

The selector that determines the group out of which the max zIndex is selected. Default: "*"