Created
January 21, 2016 20:14
-
-
Save dougwollison/8bed963a15abe55627b5 to your computer and use it in GitHub Desktop.
Get max width/height of a collection of objects.
This file contains 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
jQuery.fn.maxDimension = function( property ) { | |
var max = 0; | |
jQuery( this ).each( function() { | |
var value = jQuery( this )[ property ](); | |
if ( value > max ) { | |
max = value; | |
} | |
}); | |
return max; | |
}; | |
jQuery.fn.maxHeight = function() { | |
return jQuery( this ).maxDimension( 'height' ); | |
}; | |
jQuery.fn.maxWidth = function() { | |
return jQuery( this ).maxDimension( 'width' ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment