Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cjwebdev
Last active June 18, 2018 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjwebdev/3fe63af07f1910a5836f to your computer and use it in GitHub Desktop.
Save cjwebdev/3fe63af07f1910a5836f to your computer and use it in GitHub Desktop.
jQuery: Equal Column Heights Plugin
/*
* EqCol - Equalise Grid column heights
* Requires "Responsive Page Modes Plugin"
* http://cjweb.com.au
* Version: 1.0.0 (11-NOVEMBER-2014)
* Dual licensed under the MIT and GPL licenses.
*
* USAGE INSTRUCTIONS
* $('.grid').eqCol(); // <ul class="grid" data-eqcol-mode="medium,large" data-eqcol-item=".grid-col" >
*
*
*/
(function ($) {
$.fn.eqCol = function() {
return this.each(function() {
var container = $(this);
var item = $(this).attr('data-eqcol-item');
var modes = $(this).attr('data-eqcol-mode');
modes = modes.replace(/ /g,'');
modes = modes.split(',');
//Reset
$(item, container).removeAttr('style');
//Set if required
if ($.inArray($.responseMode.get(), modes) != -1) {
//Equalise
maxcol = 0;
$(item, container).each(function(index) {
if ($(this).height() > maxcol)
{
maxcol = $(this).height();
}
});
$(item, container).height(maxcol);
}
});
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment