diff options
author | Matt Thomas <matt@betweenbrain.com> | 2013-05-14 20:09:39 -0400 |
---|---|---|
committer | Matt Thomas <matt@betweenbrain.com> | 2013-05-14 20:09:39 -0400 |
commit | ab692d216110d2e5d6ebab53e3f982c5925d6590 (patch) | |
tree | 570799e350343f0d13e754160c77ac838bc9e379 /jquery.equalheights.js | |
parent | cca79d3ef9f6580aaf0cec92cf218827a036274c (diff) | |
download | jQuery.equalHeights-ab692d216110d2e5d6ebab53e3f982c5925d6590.zip jQuery.equalHeights-ab692d216110d2e5d6ebab53e3f982c5925d6590.tar.gz jQuery.equalHeights-ab692d216110d2e5d6ebab53e3f982c5925d6590.tar.bz2 |
Add support for initializing the plugin with data attributes data-heights="equal" and targets data-targets="div"
Diffstat (limited to 'jquery.equalheights.js')
-rw-r--r-- | jquery.equalheights.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/jquery.equalheights.js b/jquery.equalheights.js index f21303c..560fd64 100644 --- a/jquery.equalheights.js +++ b/jquery.equalheights.js @@ -10,17 +10,21 @@ */ (function($) { - $.fn.equalHeights = function() { - var maxHeight = 0, + $.fn.equalHeights = function() { + var maxHeight = 0, $this = $(this); - $this.each( function() { - var height = $(this).innerHeight(); + $this.each( function() { + var height = $(this).innerHeight(); - if ( height > maxHeight ) { maxHeight = height; } - }); + if ( height > maxHeight ) { maxHeight = height; } + }); - return $this.height(maxHeight); - }; + return $this.height(maxHeight); + }; + + // auto-initialize plugin + var target = $('[data-heights="equal"]').attr('data-targets'), init = '[data-heights="equal"] ' + target; + $(init).equalHeights(); })(jQuery); |