2012-11-06 56 views
1

我想设置一组具有流体高度但固定宽度的div的高度。为流体div设置相同的高度?

这里是我的代码:

<script type="text/javascript"> 
    $(document).ready(function() { 
     var heightArray = $(".feature_content_body").map(function() { 
      return $(this).height(); 
     }).get(); 
     var maxHeight = Math.max.apply(Math, Max, heightArray); 
     $(".feature_content_body").height(maxHeight); 
    }); 
</script> 

我不知道我要去的地方错在这里,我可以看到的代码应该使其工作逻辑...

可有人请在这里解释我的问题?

这是a demo link

回答

1

这条线......

var maxHeight = Math.max.apply(Math, Max, heightArray); 

...应该是...

var maxHeight = Math.max.apply(Math, heightArray); 

引用Max会有一个ReferenceError,除非你已经定义它,或者你正在运行此在with (Math) { }

+0

谢谢亚历克斯感谢这是问题所在。由于看了这么长时间的代码并在最近几天做了大量的页面,所以必须忽略这一点。 – Epik