How to make so that the document width is changed in real time, not after boot?

How to make so that the document width is changed in real time, not after boot?

var width = q.width = $(document).width();
June 14th 19 at 21:37
1 answer
June 14th 19 at 21:39
Solution
Exactly, or the short version
$(window).resize(function () {
 var newWidth = $(window).width();
 var newHeight = $(window).height(),
});

In contrast to the use of $(document), $(window).height() returns height of the visible part of the document, and $(document).height() returns the height of the entire document, and the visible and hidden under the scroll.
for example, this page
$(window).height(); // returns 638
$(document).height(); // returns 4575
So I have:
var width = 0;
 var height = 0;
 $(window).on('load resize', function() {
 width = q.width = $(document).width();
 height = q.height = $(document).height();
});
 console.log('W:' + width);
 console.log('In:' + height);

And do not want to work:
var width = 0;
 var height = 0;
 $(window).on('load resize', function() {
 width = q.width = $(document).width();
 height = q.height = $(document).height();
});
 console.log('W:' + width);
 console.log('In:' + height);


If I make the size of the window, then below the scrolling will not be displayed when scrolling. But I need the entire document around. - tristian56 commented on June 14th 19 at 21:42

Find more questions by tags jQuery