如何在此代码中添加一个子句,在每次调整大小之前将先前的宽度保存到变量中?
$(window).on('load resize', function() {
var w = $(window).width();
var h = $(window).height();
$('#right1').css('top' , w > 1250 ? -120 : -73 );
});
如何在此代码中添加一个子句,在每次调整大小之前将先前的宽度保存到变量中?
$(window).on('load resize', function() {
var w = $(window).width();
var h = $(window).height();
$('#right1').css('top' , w > 1250 ? -120 : -73 );
});
var oldW = $(window).width();
var oldH = $(window).height();
$(window).on('load resize', function () {
var w = $(window).width();
var h = $(window).height();
$('#right1').css('top', w > 1250 ? -120 : -73);
//Finish what you want with oldH and oldW....
oldH = h;
oldW = w;
});