Wednesday, 30 December 2015

Creating a jquery function to make all class with same height

 //Creating a jquery function to make all class with same height

function equaliseDivOnClass(class1){
                    var j = jQuery.noConflict();
     var divheights = 0;
j("."+class1).each(function( i ) {
  if(j(this).height() > divheights){
divheights = j(this).height();
  }
    });
j("."+class1).height(divheights);
   }


Usage: equaliseDivOnClass("f-desc");



------------------------------
//Creating a jquery function to make 2 div with different id same height

function equaliseDiv(div1, div2){
               var j = jQuery.noConflict();
x = j(div1).height();
y = j(div2).height();
if (x > y) {
j(div2).height(x); }
else {
j(div1).height(y);
}

   }

Usage: equaliseDiv("#s1", "#s2");

No comments :

Post a Comment