如何在此代碼中將一個子句添加到變量中,然後每次調整大小?jquery在調整大小之前保存寬度
$(window).on('load resize', function() {
var w = $(window).width();
var h = $(window).height();
$('#right1').css('top' , w > 1250 ? -120 : -73);
});
如何在此代碼中將一個子句添加到變量中,然後每次調整大小?jquery在調整大小之前保存寬度
$(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;
});
有了全局變量prevHeight和prevWidth和prevWidth = $(窗口).WIDTH(); ? – Sprottenwels
元素上有'data'? – elclanrs