How to change height div on window resize?

后端 未结 6 2088
醉话见心
醉话见心 2020-11-30 01:15

I have a div on my website that should be the height of the window. This is what i got:

    $(document).ready(function() {
    var bodyheight = $(document).h         


        
6条回答
  •  甜味超标
    2020-11-30 01:58

    You also need to do that in resize event, try this:

    $(document).ready(function() {
        $(window).resize(function() {
            var bodyheight = $(this).height();
            $("#sidebar").height(bodyheight);
        }).resize();
    });
    

提交回复
热议问题