Friday, 23 August 2013

Make two divs equal by using jQuery

Here is a simple function by which you can make two divs equal as table cells
Here is the code:-

Define the method
fn.equalizeHeights = function(){
var equalHeight =Math.max.apply(this, $(this).map(function(i,e){ return $(e).height();}).get());
 return this.height((id>=1 && id%2 ==0)?equalHeight-100:equalHeight);
}

Call the method:
$(window).load(function(){
  $('#leftmenu,#rightnav').equalizeHeights();
});

No comments:

Post a Comment