jquery.equalHeight.js 654 B

12345678910111213141516171819202122232425
  1. // make sure the $ is pointing to JQuery and not some other library
  2. (function($){
  3. // add a new method to JQuery
  4. $.fn.equalHeight = function(defaultHeight) {
  5. // find the tallest height in the collection
  6. // that was passed in (.column)
  7. var tallest = typeof defaultHeight == 'undefined' ? 0 : defaultHeight;
  8. this.each(function(){
  9. thisHeight = $(this).height();
  10. if( thisHeight > tallest)
  11. tallest = thisHeight;
  12. });
  13. // set each items height to use the tallest value found
  14. this.each(function(){
  15. if (this.id == 'm-sidebar') {
  16. $(this).height(tallest + 4);
  17. } else {
  18. $(this).height(tallest + 2);
  19. }
  20. });
  21. }
  22. })(jQuery);