Jquery problem with height() and resize()

后端 未结 2 1112
执念已碎
执念已碎 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));
                });
    
        });
    

提交回复
热议问题