【问题标题】:can't get height of object in chrome无法在 chrome 中获取对象的高度
【发布时间】:2010-03-23 02:53:21
【问题描述】:

我想获取一个对象的高度属性:

$('.selector img').each(function(index,e){   
    thisImage = $('#topContent img').get(index);
}

这么久没问题,但后来我想得到这样的高度:

thisImage.height;

我认为这相当于:

thisImage.height();

或:

thisImage.css("height");

但两者都不适合我。

最大的问题是

thisImage.height;

在 chrome 中不起作用。

我错过了什么还是这是一个已知的错误?还有其他方法可以获取 chrome 的高度吗?

【问题讨论】:

    标签: jquery get height


    【解决方案1】:

    具体而言,get() 返回的对象将是实际的 DOMElement 而不是 jQuery 对象,因此您需要将其包装在 jq 中。喜欢 $(thisImage).height() 或使用 Catfish 建议的实际选择器。

    【讨论】:

      【解决方案2】:

      试试

      var thisImage = $('#topContent img').height();
      

      【讨论】:

      • 我有点不清楚,但我需要遍历几个对象
      猜你喜欢
      • 2011-01-30
      • 2018-07-16
      • 2015-03-24
      • 2018-08-27
      • 1970-01-01
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多