调整大小功能仅在页面加载时有效

时间:2019-04-11 21:16:44

标签: javascript jquery

我有以下使div高度相等的Javascript。在初始页面加载时效果很好,并设置了高度。但是在调整大小时,它似乎没有触发。有什么想法吗?

这里是小提琴https://jsfiddle.net/caffeinehigh/ohrjLs7m/

$(window).resize(function() {

  var highestBox = 0;

      $('.casestudy-container .text').each(function(){

              if($(this).outerHeight() > highestBox) {
              highestBox = $(this).outerHeight();

      }
  });

  $('.casestudy-container .text').outerHeight(highestBox);

}).resize();

1 个答案:

答案 0 :(得分:0)

我认为您需要调整大小。以下内容似乎对我有用:

$(window).resize(function() {
  var highestBox = 0;
      $('.casestudy-container .text').each(function(){
        if($(this).outerHeight() > highestBox) {
          highestBox = $(this).outerHeight();
      }
  });

  $('.casestudy-container .text').outerHeight(highestBox);
});

在这里拨弄:https://jsfiddle.net/pvsb9kr8/1/