Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getWindowWidth2() {
- return window.innerWidth || document.body.clientWidth;
- }
- $(window).resize(function(){
- myMatchHeight('.sameHeight1'); // first group of things I want the same height
- myMatchHeight('.sameHeight2'); // second group of things I want the same height
- });
- $(window).load(function(){
- myMatchHeight('.sameHeight1');
- myMatchHeight('.sameHeight2');
- });
- function myMatchHeight(x){
- var w = getWindowWidth2(); // more accurate than $(window).width();
- //console.log('current width: ' + w);
- if (w >= 768){ // no need to resize if stacking on mobile
- var h = 0;
- $(x).each(function(){ // loop through each element with this class
- $(this).css({'height':'auto'}); // reset so it's not based on your adjusted height
- if($(this).outerHeight() > h){ // check to see if we have a new height champion
- h = $(this).outerHeight();
- }
- });
- $(x).css({'height':h}); // set all the guys with this class to the height of the tallest
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement