<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Personal blog of Chris Ergatides &#187; jQuery</title>
	<atom:link href="http://blog.ergatides.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ergatides.com</link>
	<description>jQuery, Linux, Technology, Web Design and random stuff.</description>
	<lastBuildDate>Mon, 06 Feb 2012 05:01:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Setting equal CSS heights using jQuery.</title>
		<link>http://blog.ergatides.com/2009/07/02/setting-equal-css-heights-using-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-equal-css-heights-using-jquery</link>
		<comments>http://blog.ergatides.com/2009/07/02/setting-equal-css-heights-using-jquery/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 11:18:49 +0000</pubDate>
		<dc:creator>Chris Ergatides</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[height]]></category>

		<guid isPermaLink="false">http://ergatides.com/blog/?p=1</guid>


		<description><![CDATA[<p>I recently needed to do this and found a solution over at <a href="http://www.filamentgroup.com/lab/setting_equal_heights_with_jquery/" target="_self">filament group</a>, however, I wanted the flexibility to specify the elements to work with.</p>
<p>This is what I came up with:</p>
<pre class="brush: jscript; title: ; notranslate">
(function($) {
    $.equalHeight = function(element) {
        var maxHeight = 0;
        $.each(element, function() {
            if ($(this).height() &gt; maxHeight) {
                 maxHeight = $(this).height();
            }
        });
        $.each(element, function() {
            $(this).height(maxHeight);
        });
    }
})(jQuery);
</pre>
<p>And an example of usage:</p>
<pre class="brush: jscript; title: ; notranslate">
var obj = {
    one:$(&quot;#pinned .content&quot;),
    two:$(&quot;#top10 .content&quot;)
};
$.equalHeight(obj);
</pre>
<p>Demo:<br />
<script type="text/javascript">// <![CDATA[
(function($) {
	$.equalHeight = function(element, animate) {
		var maxHeight = 0;
		$.each(element, function() {
			if ($(this).height() > maxHeight) {
				maxHeight = $(this).height();
			}
		});
		$.each(element, function() {
			if (animate) {
				$(this).fadeTo(1000, 1).animate({ "height":maxHeight }, "slow");
			} else {
				$(this).fadeTo(1000, 1).animate({ "height":maxHeight }, 0);
			}
		});
	}
})(jQuery);

function execute(animate) {
	reset();
	var obj = { one:$("#div1"), two:$("#div2"), three:$("#div3") };
	$.equalHeight(obj, animate);
}

function reset() {
	$("#div1").css("height", "50px");
	$("#div2").css("height", "100px");
	$("#div3").css("height", "75px");
}
// ]]&gt;</script></p>
<div id="div1" class="boxes" style="background-color: red; float: left; height: 50px; width: 10px;"></div>
<div id="div2" class="boxes" style="background-color: green; float: left; height: 100px; width: 10px;"></div>
<div id="div3" class="boxes" style="background-color: blue; float: left; height: 75px; width: 10px;"></div>
<p><br style="clear: both;" /><br />
<button onclick="execute(false);">TEST WITHOUT ANIMATION</button><br />
<button onclick="execute(true);">TEST WITH ANIMATION</button><br />
<button onclick="reset();">RESET</button><br />
<br style="clear: both;" /></p>
<p>No related posts.</p>]]></description>
			<content:encoded><![CDATA[<p>I recently needed to do this and found a solution over at <a href="http://www.filamentgroup.com/lab/setting_equal_heights_with_jquery/" target="_self">filament group</a>, however, I wanted the flexibility to specify the elements to work with.</p>
<p>This is what I came up with:</p>
<pre class="brush: jscript; title: ; notranslate">
(function($) {
    $.equalHeight = function(element) {
        var maxHeight = 0;
        $.each(element, function() {
            if ($(this).height() &gt; maxHeight) {
                 maxHeight = $(this).height();
            }
        });
        $.each(element, function() {
            $(this).height(maxHeight);
        });
    }
})(jQuery);
</pre>
<p>And an example of usage:</p>
<pre class="brush: jscript; title: ; notranslate">
var obj = {
    one:$(&quot;#pinned .content&quot;),
    two:$(&quot;#top10 .content&quot;)
};
$.equalHeight(obj);
</pre>
<p>Demo:<br />
<script type="text/javascript">// <![CDATA[
(function($) {
	$.equalHeight = function(element, animate) {
		var maxHeight = 0;
		$.each(element, function() {
			if ($(this).height() > maxHeight) {
				maxHeight = $(this).height();
			}
		});
		$.each(element, function() {
			if (animate) {
				$(this).fadeTo(1000, 1).animate({ "height":maxHeight }, "slow");
			} else {
				$(this).fadeTo(1000, 1).animate({ "height":maxHeight }, 0);
			}
		});
	}
})(jQuery);

function execute(animate) {
	reset();
	var obj = { one:$("#div1"), two:$("#div2"), three:$("#div3") };
	$.equalHeight(obj, animate);
}

function reset() {
	$("#div1").css("height", "50px");
	$("#div2").css("height", "100px");
	$("#div3").css("height", "75px");
}
// ]]&gt;</script></p>
<div id="div1" class="boxes" style="background-color: red; float: left; height: 50px; width: 10px;"></div>
<div id="div2" class="boxes" style="background-color: green; float: left; height: 100px; width: 10px;"></div>
<div id="div3" class="boxes" style="background-color: blue; float: left; height: 75px; width: 10px;"></div>
<p><br style="clear: both;" /><br />
<button onclick="execute(false);">TEST WITHOUT ANIMATION</button><br />
<button onclick="execute(true);">TEST WITH ANIMATION</button><br />
<button onclick="reset();">RESET</button><br />
<br style="clear: both;" /></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.ergatides.com/2009/07/02/setting-equal-css-heights-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

