简体   繁体   中英

$(window).resize(): Before

Is it possible of getting the width/height of browser each time BEFORE the resize() is triggered?

$(window).resize(function() {

});

This is due to I'm calculating the difference before/after browser has resize().

You would have to store the previous value, a little like this

var prevHeight = 0;
var prevWidth = 0;

$(document).ready(function() {
    prevHeight = $(window).height();
    prevWidth = $(window).width();
});

$(window).resize(function() {
    var currentHeight = $(window).height();
    var currentWidth = $(window).width();

    //do difference stuff

    prevHeight = currentHeight;
    prevWidth = currentWidth;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM