How would I add to the code below to work out if a DIV has any margin-top/margin-bottom? The situation I have at the moment is that I have 2 columns (DIV’s) 1 have a margin-top and the other doesn’t which causes the columns not to line up correctly.
Sorry the code has been minified and I have lost the original.
$.fn.equalHeight = function (a) {
var b = {
delay: 100,
minusHeight: 0
};
var a = $.extend(b, a);
var c = 0;
var d = 0;
var e = $(this);
setTimeout(function () {
e.each(function () {
c = $(this).outerHeight();
d = c > d ? c : d
});
return e.each(function () {
var b = $(this);
var c = d - (b.outerHeight() - b.height()) - a.minusHeight;
var e = jQuery.browser.msie && jQuery.browser.version < 7 ? "height" : "min-height";
b.css(e, c + "px")
})
}, a.delay)
};
You should add
trueas a parameter to.outerHeight()so that it includes the margin in the calculations.But there is another issue with your code.. You cannot return anything from a timeout, and you seem to have placed your return code in there..
This means you are breaking the jQuery chaining system..
Your code should probably be
Demo at http://jsfiddle.net/gaby/DXHtk/