T
T
timtimIT2015-10-09 00:10:54
JavaScript
timtimIT, 2015-10-09 00:10:54

How can I make the following code execute every time the browser window is resized?

$(document).ready(function() {
  var maxtop = 0,
  $topperblock = $('.topper-block');
  
  $topperblock.each(function(){
    if($(this).height() > maxtop){
    maxtop = $(this).height();
    }
  });
  $topperblock.each(function(){
    $(this).height(maxtop);
  });

  
  
  
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2015-10-09
@Murmurianez

$(window).resize(function(){
//code...
});

M
Maxim Martirosov, 2015-10-09
@kalbac

$(document).ready(function() {
  var maxtop = 0;
  var $topperblock = $('.topper-block');
  $(window).resize(function(){
  $topperblock.each(function(){
    if($(this).height() > maxtop){
    maxtop = $(this).height();
    }
    $(this).height(maxtop);
  }); 
});
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question