好日子計算高度和增加了可變
我有以下函數,計算每個div的高度,並將其添加到一個變量,但它不工作:
JS:
$('#latestInner, #make, #models').each(function() {
var i = 0;
var h = $(this).outerHeight();
i = i + h;
});
alert(i);
HTML:
<div id="latestInner"></div>
<div id="make"></div>
<div id="models"></div>
CSS:
#models {height: 100px; background: red;}
#latestInner {height: 200px; background: green;}
#make {height: 150px; background: blue;}
FIDDLE:http://jsfiddle.net/uwsJH/7/
是的,非常感謝你 –
不客氣;-) – Tschallacka