1
我的函數有一個問題,它會在發生頁面大小調整時計算每個div部分的高度。它顯示了結果後的相同高度值。但是在第一頁加載時一切正常。問題在哪裏?jquery |動態改變div的高度onresize
JS
$(document).ready(function() {
$(window).bind('orientationchange resize', function(e){
resize();
}).trigger('resize');
});
function resize() {
var vph = $(window).height();
$.each($('.st-panel'), function(index, value) {
var section_height = $(this).height() < vph ? vph : $(this).height();
$(this).height(section_height);
});
}
HTML
<section class="st-panel" id="st-panel-1">...long text here...</section>
<section class="st-panel" id="st-panel-2">...long text here...</section>
<section class="st-panel" id="st-panel-3">...long text here...</section>
<section class="st-panel" id="st-panel-4">...long text here...</section>
<section class="st-panel" id="st-panel-5">...long text here...</section>