【发布时间】:2012-01-15 21:57:50
【问题描述】:
我在 stack overflor 上看到了很多东西来获得最高的 div,但没有一个对我有用。我需要获取 div preview_txt 的高度。
<div class="headline" data-rating="0.482005543693" onclick="javascript:showArticle(1076);" style="display: none; ">
<div class="headline_txt">
<h1>#3726: Meryl Streep schittert in The Iron Lady- alle recensies op een rijtje</h1>
</div>
<div class="preview_txt">
<p>
De eerste foto's van actrice Meryl Streep als de Britse voormalig premier Margaret Thatcher
<a href="http://www.guardian.co.uk/film/2011/feb/08/meryl-streep-margaret-thatcher-iron-lady#">
leidden
</a>
vorig jaar al tot een stortvloed aan publiciteit. Nu is
<a href="http://www.imdb.com/title/tt1007029/">
<em>The Iron Lady</em>
</a>
er dan ook echt. Vanaf vandaag draait de film in de Nederlandse bioscopen. Lees hier alle recensies.
<!--more-->
</p>
</div>
</div>
从我看到的东西来看,我认为我最喜欢这个:
var maxHeadLineHeight = Math.max.apply(Math, $("#headline").map(
function(){
return $(this).height();
}
));
console.log("maxHeadLineHeight: "+maxHeadLineHeight);
但这给了我:
Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type
我也试过这样:
"#headline .preview_txt"
虽然在哪里,为每个标题 div 设置高度将是下一个,但这可能不会那么不同(通过获取对象)。
【问题讨论】: