Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- // jQuery plugin definition
- $.fn.pushLayers = function(params) {
- //alert($(this).css('z-index'));
- var numElems = $(this).parent().children().length; //get number of DOM nodes in the continer DIV
- var removed_index = $(this).css('z-index');
- // merge default and user parameters
- params = $.extend( {numElements: numElems, removedZ: removed_index}, params);
- // traverse all nodes
- $(this).parent().children().each(function() /*this is an anonymous function*/{
- // express a single node as a jQuery object
- //var $t = $(this);
- // if z-index is greater than the z-index of removed card, decrease z-index by 1.
- if ($(this).css('z-index') > removedZ) {
- //decrease z-index
- $(this).css('z-index', parseInt($(this).css('z-index'))-1);
- }
- // remove card and place it at front
- if ($(this).css('z-index') == removed_index){
- $(this).css('z-index', numElems);
- }
- });
- // allow jQuery chaining
- return this;
- };
- })(jQuery);
Add Comment
Please, Sign In to add comment