Jquery problem with height() and resize()

后端 未结 2 1111
执念已碎
执念已碎 2020-12-21 14:42

I need to give an element a specific height based on document\'s height and keep it whether the document size changes:

$(document).ready(function () {
    $(         


        
相关标签:
2条回答
  • 2020-12-21 15:02

    To calculate the height, try replacing document by window:

        $(document).ready(function () {
                $('#descriptive_news_text').height(($(window).height() - 325));
                $(window).resize(function () {
                        $('#descriptive_news_text').height(($(window).height() - 325));
                });
    
        });
    
    0 讨论(0)
  • 2020-12-21 15:11

    Something like this seems to work fine for me:

    $(function() {
        $("div#test").css("height", ($(document).height() - 325) + "px");
    });
    
    0 讨论(0)
提交回复
热议问题