高度()和大小()的Jquery问题

高度()和大小()的Jquery问题,jquery,resize,height,Jquery,Resize,Height,我需要根据文档的高度为元素指定一个特定的高度,并在文档大小发生变化时保留该高度: $(document).ready(function () { $('#descriptive_news_text').height(($(document).height() - 325)); $(window).resize(function () { $('#descriptive_news_text').height(($(document).height() - 325))

我需要根据文档的高度为元素指定一个特定的高度,并在文档大小发生变化时保留该高度:

$(document).ready(function () {
    $('#descriptive_news_text').height(($(document).height() - 325));
    $(window).resize(function () {
        $('#descriptive_news_text').height(($(document).height() - 325));
    });

});
$(function() {
    $("div#test").css("height", ($(document).height() - 325) + "px");
});
现在,当我手动调整浏览器的大小时,它就像一个符咒一样工作,但是在页面加载时,文档大小的计算方式是错误的,因此div的高度也是错误的。我试图强制将
$(windows).resize()作为最后一条语句(作为测试,即使延迟几秒钟),但这不起作用,因为jQuery在手动调整大小后才识别正确的高度

$(function() {
    $("div#test").css("height", ($(document).height() - 325) + "px");
});
此外,双击或通过窗口(Chrome,Windows)的“调整大小”按钮调整窗口大小,似乎不会像拖动窗口边缘那样触发“调整大小”事件

$(function() {
    $("div#test").css("height", ($(document).height() - 325) + "px");
});

有什么帮助吗?

像这样的东西似乎对我很管用:

$(function() {
    $("div#test").css("height", ($(document).height() - 325) + "px");
});

要计算高度,请尝试按窗口替换文档:

$(function() {
    $("div#test").css("height", ($(document).height() - 325) + "px");
});
    $(document).ready(function () {
            $('#descriptive_news_text').height(($(window).height() - 325));
            $(window).resize(function () {
                    $('#descriptive_news_text').height(($(window).height() - 325));
            });

    });