为流体div设置相同的高度? [英] Setting the same height to fluid div's?

查看:101
本文介绍了为流体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 href =http://jsfiddle.net/zzf7r/1/ =nofollow>一个演示链接。 解决方案

这行...
$ b $ pre $ var $ maxHeight = Math.max.apply(Math,Max,heightArray) ;

...应该是...

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

引用最大值会有一个 ReferenceError ,除非你已经定义了它,或者你正在中用(Math){} 来运行。


I am trying to set the same height of a group of div's that have a fluid height but a fixed width.

Here is my code:

<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>

I am not sure where i am going wrong here as i can see the logic in the code that should make it work...

Can someone please shed some light on my issue here?

Here is a demo link.

解决方案

This line...

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

...should be...

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

Referencing Max there will be a ReferenceError, unless you have defined it or you're running this in with (Math) { }.

这篇关于为流体div设置相同的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆