Last active
September 20, 2017 01:06
-
-
Save bryanrsebastian/a2d2be8f10d47b958eb080bbb48539e9 to your computer and use it in GitHub Desktop.
By using this function you can set the height of all elements dynamically base on the max height of the selector.
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
( function( $ ) { | |
/** | |
* Script On Document Ready | |
*/ | |
autoHeight( '[selector]' ); | |
/** | |
* Script On Resize | |
*/ | |
$( window ).resize( function() { | |
autoHeight( '[selector]' ); | |
} ); | |
/** | |
* Functions | |
*/ | |
function autoHeight( resource ) { | |
$( resource ).height( 'auto' ); | |
var maxHeight = Math.max.apply( null, $( resource ).map( function() { | |
return $( this ).height(); | |
} ).get() ); | |
$( resource ).height( maxHeight ); | |
} | |
} ( jQuery ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment