Answer the question
In order to leave comments, you need to log in
How to get current viewport width?
How can I get the current width of the viewport so that when the page is reloaded or the window is resized, it remains correct?
Answer the question
In order to leave comments, you need to log in
Somehow there may be errors in the syntax, but the logic is simple, get the width of the window, and listen to the resize event of this window, and you will always have the desired width width
var width = Resize();
$(window).resize(function(){
width = Resize();
});
function Resize(){
return window.clientWidth;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question